Can I get the current executing controller from HttpContext?

前端 未结 2 1138
终归单人心
终归单人心 2021-02-14 18:32

I am using some 3rd party classes. I want to get the routevalues of my controller in that. Unfortunately it doesn\'t hand me the current controller that is executing. Can I get

相关标签:
2条回答
  • 2021-02-14 18:36

    You can search the values of "controller" and "action" in this object

    HttpContext.Request.RequestContext.RouteData.Values
    
    0 讨论(0)
  • 2021-02-14 18:56

    Not sure in what context you are executing, but you can get it from the RequestContext:

    RequestContext.RouteData.Values["controller"].ToString()
    
    0 讨论(0)
提交回复
热议问题