Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable default validation in Asp.Net WebAPI

I want to completely disable model validation for WebAPI controllers. I tried a few ways to do it for MVC, but seems WebAPI doesn't get that methods.

In my case:

  1. custom formatter creates and populates object
  2. default validation happens
  3. Object passed to controller
  4. My code start working

I'm trying to completely remove step 2.

like image 638
Oleh Nechytailo Avatar asked Dec 11 '22 14:12

Oleh Nechytailo


1 Answers

Try this:

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

It should completely disable validation both for URI parameters and for body parameters.

like image 50
Youssef Moussaoui Avatar answered Dec 29 '22 05:12

Youssef Moussaoui