You can provide your custom request validation instead.
public class NormalizingRequestValidator : RequestValidator
{
protected override bool IsValidRequestString(HttpContext context, string value, RequestValidationSource requestValidationSource, string collectionKey, out int validationFailureIndex)
{
return base.IsValidRequestString(context, value.Normalize(NormalizationForm.FormKC), requestValidationSource, collectionKey, out validationFailureIndex);
}
}
In web.config
<system.web>
<httpRuntime targetFramework="4.5" requestValidationType="YourNamespace.NormalizingRequestValidator, YourAssembly" />
</system.web>
If also want to normalize the string you receive in your controllers, implement a custom ValueProviderFactory
. See What’s the Difference Between a Value Provider and Model Binder?
Note: if you choose to only implement a ValueProviderFactory
, you will have to call RequestValidator.Current
to manually validate the normalized string.