In MVC3, how to get the current action name?

后端 未结 2 1723
天命终不由人
天命终不由人 2021-01-13 01:30

Is there a way to use HttpContext or the View context to get the current action name?

I can get the controller name using

    var routeValues = Http         


        
2条回答
  •  孤城傲影
    2021-01-13 02:11

    ViewContext.RouteData.Values["action"]
    

    As far as I know, ViewContext.RouteData.Values will never be null and will always have the keys "controller" and "action". Please correct me if I am wrong.

提交回复
热议问题