ASP.NET MVC 4 RC: Get current controller name from HttpContext


To find out the name of the current controller from a HTTP context, you can use the following code snippet:

        
var controllerName = RouteTable.Routes.GetRouteData(
  new HttpContextWrapper(HttpContext.Current)
).Values["controller"].ToString();
,

Leave a Reply

Your email address will not be published. Required fields are marked *