UrlHelper.GenerateUrl in ASP.NET MVC

The UrlHelper.GenerateUrl in ASP.NET MVC can be used to return a string which contains the URL.

UrlHelper.GenerateUrl in ASP.NET MVC

The UrlHelper.GenerateUrl takes 7 parameters (overloaded). These parameters include

  • RouteName
  • ActionName
  • ControllerName
  • Route Values
  • Route Collection
  • Request Context
  • Include Implicit Mvc Values

Below is a sample code snippet demonstrating the UrlHelper.GenerateUrl

string result = UrlHelper.GenerateUrl(null, "Login", "Account", null, routes, context, false);