How to get the URL of the current page in ASP.NET MVC Action Method ?

Your 2020 Plan. Learn 20 minutes a day for 20 days. Online courses from €9.99.

If you want to get the current URL from an action method in ASP.NET MVC project , you can use the Request.Url.AbsoluteUri property .

How to get the URL of the current page in ASP.NET MVC Action Method ?

Below is a sample code snippet demonstrating how to get the current URL in ASP.NET MVC.

public ActionResult Index()
{
    string CompleteUrl = this.Request.Url.AbsoluteUri;
    return View();
}

image

Leave a Reply

Your email address will not be published. Required fields are marked *