Phalanger icon indicating copy to clipboard operation
Phalanger copied to clipboard

Find Current Page URL

Open sandeepsri opened this issue 8 years ago • 4 comments

How to find current page URL $pageURL = $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; getting error "Notice: Undefined offset"

System\Web\HttpContext::$Current->Request->Url->AbsoluteUri; getting error "Notice: An empty variable used as an object"

sandeepsri avatar Mar 08 '16 12:03 sandeepsri

WFM.

a file with the following content works as expected on the Visual Studio development server:

<?php
echo $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'];

output:

localhost:62931/test.php

lucyllewy avatar Mar 08 '16 18:03 lucyllewy

I am writing output Filter for Apache 2.4 web server, when I am running this with Apache then getting "Notice: Undefined offset (SERVER_NAME). Notice: Undefined offset (SERVER_PORT). Notice: Undefined offset (REQUEST_URI)."

sandeepsri avatar Mar 09 '16 08:03 sandeepsri

Can you run a script which outputs the $_SERVER variable via print_r() to try to figure-out the relevant keys. ASP.NET is not meant to operate as an Apache output filter by default, and Phalanger less-so. The $_SERVER variable is set from the environment variables set by Apache so if the hostname wasn't set by Apache then Phalanger cannot know what to set $_SERVER['SERVER_NAME'] to internally.

lucyllewy avatar Aug 19 '16 21:08 lucyllewy

@sandeepsri Phalanger's development is mostly discontinued in favor of PeachPie, the more modern compiler and runtime that also targets .NET Core. Please feel free to give that a try. @diddledan already knows about it :)

bfistein avatar Sep 19 '18 20:09 bfistein