How to get controller and action name in OnActionExecuting?

Is it possible to figure out the currently executing controller/action in OnActionExecuting?


You could try the ActionDescriptor of the ActionExecutingContext as follows:

protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
   string actionName = filterContext.ActionDescriptor.ActionName;
   string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName
   .....
   base.OnActionExecuting(filterContext);
}

You can use ActionDescriptor of ActionExecutingContext

protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
    var descriptor = filterContext.ActionDescriptor;
    var actionName = descriptor.ActionName;
    var controllerName = descriptor.ControllerDescriptor.ControllerName;
    ......
    base.OnActionExecuting(filterContext);
}