How to get the current URL of the browser in ASP.NET?

Posted by Poster under ASP.NET category on | Views : 21570
To get the URL of the browser:

To get the host name of the url :

Comments or Responses

Posted by: Dotnetservices on: 11/2/2016 Level:Starter | Status: [Member] | Points: 10
// To get the absolute URL (http://localhost:8080/folder/YourPage.aspx)
string url = HttpContext.Current.Request.Url.AbsoluteUri;

// To get the absolute path (/folder/YourPage.aspx)
string path = HttpContext.Current.Request.Url.AbsolutePath;
// To get the host (localhost)
string host = HttpContext.Current.Request.Url.Host;
For any other .net related query, you can also contact our developer team.

Login to post response