As the title mentioned, i want to disable automatic ModelState Validation for a specific Controller / Action.
Is that possible ?
Consider clearing the Modelstate
dictionary in the controller action instead by calling:
Modelstate.Clear();
I think it is possible. Create custom ModelValidatorProvider.
public class CustomModelValidatorProvider
: DataAnnotationsModelValidatorProvider
{
protected override IEnumerable<ModelValidator> GetValidators(
ModelMetadata metadata,
ControllerContext context,
IEnumerable<Attribute> attributes)
{
return Enumerable.Empty<ModelValidator>();
}
}
and set this provider at startup.
ModelValidatorProviders.Providers.Clear();
ModelValidatorProviders.Providers.Add(new CustomModelValidatorProvider());
How about this?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With