ASP.NET: How to get URL of the current page in c#


Try this :
string url = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost:1302/TESTERS/Default6.aspx
Get Application name and page name:
string path = HttpContext.Current.Request.Url.AbsolutePath;
// /TESTERS/Default6.aspx
Get Application Rooth path:
string host = HttpContext.Current.Request.Url.Host;
// localhost
Get Full URL:
// http://localhost:1302/TESTERS/Default6.aspx?page=1
URI variable:

Uri uri= HttpContext.Current.Request.Url;

String host = uri.Scheme + Uri.SchemeDelimiter + uri.Host + “:” + uri.Port;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s