In MVC3, how to get the name of the current controller?

Is there a method from the http context class to get the current controller name?

+5
source share
1 answer

Yes, you can do something like this

HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString();

If you are in view mode, you can do:

ViewContext.RouteData.Values["Controller"]
+11
source

All Articles