string controllerName = 
(string)htmlHelper.ViewContext.RouteData.GetRequiredString("controller");

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

在 controller 中可以使用 ControllerContext 取得:

1
2
ControllerContext.RouteData.Values["controller"]
ControllerContext.RouteData.Values["action"]


在 view 中可以使用 ViewContext:

1
2
ViewContext.RouteData.Values["controller"]
ViewContext.RouteData.Values["action"]

相关文章:

  • 2021-11-25
  • 2022-01-04
  • 2021-11-01
  • 2022-12-23
猜你喜欢
  • 2022-02-15
  • 2021-08-14
  • 2021-12-28
  • 2022-12-23
  • 2021-08-03
相关资源
相似解决方案