Oleh Nechytailo
Oleh Nechytailo

Reputation: 2195

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.

Upvotes: 5

Views: 4113

Answers (1)

Youssef Moussaoui
Youssef Moussaoui

Reputation: 12395

Try this:

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

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

Upvotes: 13

Related Questions