When including MVC filters, I understand that they can be registered in the following locations
- Global (FilterConfig.cs)
- Controller Level
- Action level
I also know that there are 4 types and that they are executed in the following order:
- Authorization filters
- Action filters
- Response filters
- Exception filters
However, I'm a little confused on priority here:
- Are the locations executed in the order shown?
- Assuming that the location is executed in order, which takes priority: type or location?
- What happens if multiple filters of the same type are declared in the same location? Are they executed in the order they are defined?
For example if I have 6 filters as below, in what order will they be executed?
// FilterConfig.cs
filters.Add(new AuthorizationFilter());
filters.Add(new ActionFilter());
-
// MyController.cs
[AuthorizationFilter2]
[ActionFilter2]
public class MyController
{
[AuthorizationFilter3]
[ActionFilter3]
public ActionResult MyAction()
{
return foo;
}
}