I've setup a custom ActionFilterAttribute for my WebAPI
Is there a way to apply this to all WebAPI controllers at once, versus adding the [ActionFilter] to every single WebAPI controller?
I've setup a custom ActionFilterAttribute for my WebAPI
Is there a way to apply this to all WebAPI controllers at once, versus adding the [ActionFilter] to every single WebAPI controller?
You can add your action filter attribute to global filters which applies to all API controllers from WebApiConfig class's Register method.
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
config.Filters.Add(new TestFilterAttribute());
}
}
© 2022 - 2024 — McMap. All rights reserved.