ASP.NET Core Action Filter Doesn't Get Called

Adding the following line to Startup.cs, ConfigureServices() method resolved the issue. turns out .Net Core has automatic 400 responses enabled by default. If you want to add custom Action Filters, you need to set those options at the startup.

services.Configure<ApiBehaviorOptions>(options =>
{
      options.SuppressModelStateInvalidFilter = true;
});

It's well documented here on the Microsoft site:

https://docs.microsoft.com/en-us/aspnet/core/web-api/index?view=aspnetcore-2.1#automatic-http-400-responses


The [ApiController] attributes performs model validation automatically and triggers an HTTP response of 404, in .Net Core 3.0 you can chain to the new AddControllers() to suppress this feature:

services.AddControllers()
                .ConfigureApiBehaviorOptions(options =>
                {
                    options.SuppressModelStateInvalidFilter = true;
                });