Reputation: 12438
How can I check what ActionFilterAttributes are applied from within OnActionExecuting in my Controller?
Upvotes: 0
Views: 130
Reputation: 7385
Maybe it helps you:
[HttpGet]
public ActionResult Index()
{
var attributes = Attribute.GetCustomAttributes(typeof(HomeController).GetMember("Index").First());
return View();
}
And result hould be like this:
UPDATE
var onlyActionFilterAttributesForClass =
typeof(HomeController).GetCustomAttributes(true).Where(
x => x as ActionFilterAttribute != null);
var onlyActionFilterAttributesForMember = Attribute.GetCustomAttributes(typeof (HomeController).GetMember("Index").First()).
Where(
x => x as ActionFilterAttribute != null);
Upvotes: 1