I want to use IOverrideFilter
interface to override my custom global filter but it is simply not working! Code looks like to be as follow:
public se
The msdn info is not entirely clear about it but IOverrideFilter.FiltersToOverride must be exactly one of the following:
IActionFilter
IAuthorizationFilter
IAuthenticationFilter
IExceptionFilter
Basically, you cannot override specific filters, you can only override all the filters of one of the categories above. Have a look a the ProcessOverrideFilters
method in the source code.
So, let's say that your ITest
filter is of type IActionFilter
, then your override will be (The same logic would apply for any other filter category):
public Type FiltersToOverride
{
get { return typeof(IActionFilter); }
}
You could also use the predefined OverrideActionFilters (and similar predefined override attributes for other filter categories).
For a more fine-grained override, you might need to develop specific solutions like this one or write your own filter provider as in this very nice article