Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FilterAttribute Order not working

I have 2 attributes that I use within the controllers of my MVC application. AttributeA extends System.Web.Mvc.AuthorizeAttribute and AttributeB extends System.Web.Mvc.ActionFilterAttribute. I want AttributeB to always be run first.

I have tried all possible combinations of Order based on this article, but AttributeA is always run before AttributeB. Can anyone help?

like image 275
Chris Arnold Avatar asked Nov 09 '09 14:11

Chris Arnold


1 Answers

If you look at the System.Web.Mvc.ControllerActionInvoker.InvokeAction method with reflector you will see that all filters implementing IAuthorizationFilter are invoked before attributes deriving from ActionFilterAttribute and that's because authorization is made before invoking the action.

like image 92
Darin Dimitrov Avatar answered Nov 07 '22 01:11

Darin Dimitrov