Home > Backend Development > C++ > How to Get the Current Page URL in ASP.NET using C#?

How to Get the Current Page URL in ASP.NET using C#?

Mary-Kate Olsen
Release: 2025-01-11 07:32:43
Original
283 people have browsed it

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;
Copy after login

Additional Options:

If you require only a specific component of the URL:

  • Absolute Path:

    string path = HttpContext.Current.Request.Url.AbsolutePath;
    Copy after login
  • Host Name:

    string host = HttpContext.Current.Request.Url.Host;
    Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template