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

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 *

You May Also Like

You can pass an array of integer to an ASP.NET Web Web API REST service by setting the [FromUri] attribute...
One of the common ways to refresh webpage every few mins is by using JavaScript or HTML Meta tag. For...
This post will provide the list of some of the top ASP.NET based Content Management Systems (CMS) that you may...