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

Poster
Posted by Poster under ASP.NET category on | Views : 20242
To get the URL of the browser:
Request.ServerVariables["URL"]


To get the host name of the url :
Request.ServerVariables["SCRIPT_NAME"]

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 asp.net developer http://www.teaminindia.co.uk/hire-asp.net-developer.htm team.

Login to post response