Can I get the current executing controller from HttpContext?

前端 未结 2 1140
终归单人心
终归单人心 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:56

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

    RequestContext.RouteData.Values["controller"].ToString()
    

提交回复
热议问题