Phalanger
Phalanger copied to clipboard
Find Current Page URL
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"
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
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)."
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.
@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 :)