Url.Action() for Areas
28-12-2015 17:07:14
C# / ASP.NET MVC
0 Bookmark(s)
359 View(s)
public static class UrlHelperExtensions
{
public static string ActionForArea(this UrlHelper urlHelper, string area,
string controllerName = null, string actionName = null, object routeValues = null)
{
var routeValueDictionary = new RouteValueDictionary(routeValues) { { "Area", area } };
return urlHelper.Action(actionName ?? string.Empty,
controllerName ?? string.Empty, routeValueDictionary);
}
}