How to get current page URL in ASP.NET

To get the current page URL you could use HttpContext.Current.Request.Url:

1. To get the full URL with query string (if any) you could use:

string absoluteurl = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost:80/test/Default.aspx?test=1

2. To get the path without the domain you could use:

string absolutepath = HttpContext.Current.Request.Url.AbsolutePath;
// /test/Default.aspx

3. To get the Host:

string host = HttpContext.Current.Request.Url.Host;
// localhost

Related TutorialsHow to associate a Label with a […]

How to create new aspx web page

To add a page to the Web site:
In Solution Explorer, right-click the Web site (for example, C:\HowToASPNET), and then click Add New Item.

The Add New Item dialog box is displayed.

In the template list, select Web Form.
In the Name box, type the name of the new aspx page, by example MyNewPage.
Click Add.

Visual Studio creates the new aspx page […]

Recommended ASP.NET Examples