FilterAttribute Order not working

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

I tried all possible Order combinations based on in this article , but AttributeA always works and runs before AttributeB. Can anyone help?

+5
source share
1 answer

If you look at the method System.Web.Mvc.ControllerActionInvoker.InvokeActionwith a reflector, you will see that all filters that implement the IAuthorizationFilter are called before the attributes originating from the ActionFilterAttribute and that, since authorization is performed before the action is called.

+6
source

All Articles