Disable default validation in Asp.Net WebAPI

I want to completely disable model validation for WebAPI controllers. I tried several ways to do this for MVC, but it seems like the WebAPI is not getting these methods.

In my case:

  • Custom formatter creates and populates an object
  • default check performed
  • Object transferred to controller
  • My code starts to work

I am trying to completely remove step 2.

+4
source share
1 answer

Try the following:

config.Services.Clear(typeof(ModelValidatorProvider)); 

It should completely disable checking both URI parameters and body parameters.

+11
source

Source: https://habr.com/ru/post/1482227/


All Articles