Find Area name and Controller Name in custom Htmlhelper with ASP.NET MVC3

后端 未结 3 1128
情深已故
情深已故 2021-02-08 12:10

I try to rewrite and customize @Html.ActionLink, in one of overloads of this method the parameters are:

public static MvcHtmlString ActionLink(this         


        
3条回答
  •  [愿得一人]
    2021-02-08 12:24

    Use this:

    string controllerName = 
    (string)htmlHelper.ViewContext.RouteData.GetRequiredString("controller");
    
    string areaName = 
    (string)htmlHelper.ViewContext.RouteData.DataTokens["area"];
    

提交回复
热议问题