jasontaylordev / NorthwindTraders

Northwind Traders is a sample application built using ASP.NET Core and Entity Framework Core.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prevent Api from auto return bad request response without firing CustomExceptionFilterAttribute

Bebarsse opened this issue · comments

In case if a controller action with an invalid ModelState , the Api return by default a 400 Bad Request without firing the CustomExceptionFilterAttribute .

The behaviour of the api must be changed with adding services.Configure<ApiBehaviorOptions>(options => { options.SuppressModelStateInvalidFilter = true; }); on the startup class to allow CustomExceptionFilterAttribute handling these exceptions.