Home >Backend Development >C++ >How to Get the Current Page URL in ASP.NET using C#?
Retrieving the Current Page URL in C# for ASP.NET
Seeking the ability to retrieve the URL of the currently rendered page in an ASP.NET application? C# offers a straightforward solution:
Solution:
To obtain the complete absolute URL of the current page:
string url = HttpContext.Current.Request.Url.AbsoluteUri;
Additional Options:
If you require only a specific component of the URL:
Absolute Path:
string path = HttpContext.Current.Request.Url.AbsolutePath;
Host Name:
string host = HttpContext.Current.Request.Url.Host;
The above is the detailed content of How to Get the Current Page URL in ASP.NET using C#?. For more information, please follow other related articles on the PHP Chinese website!