AbdElRaheim
AbdElRaheim

Reputation: 1394

from an MVC 4.0 ActionFilterAttribute how do I get the current ApiController

I am trying to get the current ApiController from the filterContext. It exposes a controller property but the ApiController implements some httpcontroller interface and is not there.

    public override void OnActionExecuting(ActionExecutingContext filterContext)

Upvotes: 1

Views: 674

Answers (1)

vcsjones
vcsjones

Reputation: 141588

You would cast it back to your ApiController. Something like this:

var apiController = filterContext.Controller as ApiController;
if (apiController != null)
{
    //Do something with apiController.
}

Upvotes: 2

Related Questions