Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

Find Current Page URL #65

Open
sandeepsri opened this issue Mar 8, 2016 · 4 comments
Open

Find Current Page URL #65

sandeepsri opened this issue Mar 8, 2016 · 4 comments

Comments

@sandeepsri
Copy link

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"

@lucyllewy
Copy link

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

@sandeepsri
Copy link
Author

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)."

@lucyllewy
Copy link

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.

@bfistein
Copy link
Contributor

@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 :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants