views:

42

answers:

1

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?

+2  A: 

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.

Darin Dimitrov