New! GraphQL.NET Cookbook by Senthil Kumar Balu

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

Senthil Kumar B
Senthil Kumar is a former Microsoft MVP (Most Valuable Professional). He is a Co-Author of the book "Windows 10 Development Recipes using JavaScript and CSS" for Apress Publication. He is a technical presenter, blogger, mentor and a Geek.  Senthil is a regular speaker is various local user groups. He has presented at conferences like Great Indian Developer Summit (GIDS) & Microsoft DevCamps. You can reach out to him via his Twitter handle @isenthil.