Search code examples
asp.net-mvcaction-filterorder-of-execution

Order property of ActionFilter, from lowest to greatest or vice versa?


I defined two ActionFilters:

[DefaultResources(Order = 2)]
[RenderTemplate(Order = 1)]

And to my surprise DefaultResources is executed BEFORE RenderTemplate. But according to MSDN documentation it should work vice versa:

[Filter1(Order = 2)]
[Filter2(Order = 3)]
[Filter3(Order = 1)]
public void Index()
{
    View("Index");
}

In this example, action filters would execute in the following order: Filter3, Filter1, and then Filter2.

I'm using .NET 4. And comparing by method OnActionExecuted. Am I missing something?


Solution

  • Last-in First-out order

    This is the answer I was looking for. Order of OnActionExecuted is reversed order of OnActionExecuting...