Q:

How to get ActionDescriptor using action and controller names

Given the action name, controller name and HTTP verb (GET, POST .. etc), is it possible to check whether the action has (ie. is decorated by) a specific action filter attribute?
Please note: The action and controller are not the current action and controller but can be any action and controller in the app.
Thanks!

A:

I have answered my own question, that is very similar to this.

question: How do I get the MethodInfo of an action, given action, controller and area names?
answer: https://stackoverflow.com/a/13044838/195417

You will also need the http method (that is GET, POST) to get the correct result, in addition to action and controller names.
This is the piece of the code that solves your problem:
var controllerFactory = ControllerBuilder.Current
    .GetControllerFactory();

var controllerContext = @this.ControllerContext;

var otherController = (ControllerBase)controllerFactory
    .CreateController(
        new RequestContext(controllerContext.HttpContext, new RouteData()),
        controllerName);

var controllerDescriptor = new ReflectedControllerDescriptor(
    otherController.GetType());

var controllerContext2 = new ControllerContext(
    new MockHttpContextWrapper(
        controllerContext.HttpContext.ApplicationInstance.Context,
        method),
    new RouteData(),
    otherController);

var actionDescriptor = controllerDescriptor
    .FindAction(controllerContext2, actionName);

