What is the execution order of global filters MVC 4
action-filter, asp.net-mvc-4
Solution
As no answer has thusfar been given about how to specify the order of global filters in RegisterGlobalFilters, here's my answer:
You can specify the order in the Add method, by passing in a second parameter:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute(), 1);
filters.Add(new LogFilter(), 2);
}
Problem
I have 2 global action filters in my MVC 4 application, that I've registered in Filter.config file using RegisterGlobalFilters. I need them to be executed in a particular order. I know how to specify order for Controller specific filters but how do I specify order and scope for my global filters? is it in the order in which they are registered?