Getting the name of the controller and action method in the view in ASP.Net MVC

后端 未结 2 1459
孤独总比滥情好
孤独总比滥情好 2020-12-01 09:24

Is there a way in a view in ASP.Net MVC to get the names of the controller and actien method that are using the view?

2条回答
  •  伪装坚强ぢ
    2020-12-01 09:37

    Try this:

    <%= ViewContext.RouteData.Values["Controller"] %>
    <%= ViewContext.RouteData.Values["Action"] %>
    

提交回复
热议问题