Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get full url address

I want to get full url, in ASp.NET MVC 4, for example user entered url:

http://localhost:5555/#globalName=MainLines&ItemId=5

And when I try to get this url in Global.asax, I get only http://localhost:5555/

protected void Application_BeginRequest(object sender, EventArgs e)
{
    var url = HttpContext.Current.Request.Url;
}

Thanks

like image 417
Eugene Smirnov Avatar asked Jun 07 '13 07:06

Eugene Smirnov


People also ask

How can I get browser URL in php?

To get the current page URL, PHP provides a superglobal variable $_SERVER. The $_SERVER is a built-in variable of PHP, which is used to get the current page URL. It is a superglobal variable, means it is always available in all scope.

How can I get localhost URL in php?

You can use this: <? php $url = 'http://'.($_SERVER['SERVER_NAME']==='localhost')?'localhost/PROJECTNAME':$_SERVER['SERVER_NAME']; echo $url; ?> – DS.


1 Answers

That's impossible. The part that is following the fragment (#) is never sent to the server in the HTTP request and the server has no way of retrieving it. Fragments can only be accessed by javascript. So if you want to retrieve this value on the server you will have to use javascript to read it and then store it in some hidden field or something so that it gets sent to the server.

like image 133
Darin Dimitrov Avatar answered Oct 06 '22 11:10

Darin Dimitrov