问题
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:
- custom formatter creates and populates object
- default validation happens
- Object passed to controller
- My code start working
I'm trying to completely remove step 2.
回答1:
Try this:
config.Services.Clear(typeof(ModelValidatorProvider));
It should completely disable validation both for URI parameters and for body parameters.
来源:https://stackoverflow.com/questions/16698770/disable-default-validation-in-asp-net-webapi