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

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

You May Also Like

You can read connection string from web.config file in ASP.NET by using the ConfigurationManager class in case you want to...
When you deploy your ASP.NET Web Application on Windows Server running IIS , there are times that you might receive...
This post will explain how to resolve the error “Handler “aspNetCore” has a bad module “AspNetCoreModuleV2” in its module list”...