This is a fix for the specific case reported in #3743 and also a few
related cases where the object being validated does not come from user
input.
Because the CancellationToken is bound using the 'empty prefix',
suppressing validation causes the validation system to suppress ALL keys
in the MSD. This will wipe out validation info for other, unrelated model
data. The same can occur for [FromServices], IFormCollection, IFormFile,
and HttpRequestMessage (anythere when MSD key == null and
SuppressValidation == true).
The other change here is related to the [FromBody]. We don't want to
create an entry in the model state for a 'valid' model with the empty
prefix. This can cause the system to miss validation errors. If you end up
in a situation where there's an entry with the empty prefix for an invalid
state, you won't accidentally miss validation errors.
- #2969
- `RemoteAttribute` did not support `IStringLocalizer` overrides
- use same `MvcDataAnnotationsLocalizationOptions` property as for other `ValidationAttribute`s
- error message `NumericClientModelValidator` added could not be overridden
- not related to `IStringLocalizer` because users have no way to set the resource lookup key
- extend `IModelBindingMessageProvider` to add the necessary `Func<,>`
- also correct problem using resources with `RemoteAttribute` and add lots of tests
* Add an UnsupportedContentType to the ModelState dictionary when no formatter can read the body.
* Add a filter to the pipeline that searches for that specific exception and transforms the response into 415.
This change removes a layer of abstraction. These validators now just do
what they do now without creating a bunch of intermediate objects.
ModelClientValidationRule has been removed, and client validations
manipulate the attributes collection of a tag directly.
* Added a Release method to IControllerActivator
* Changed Create in IControllerActivator to take in a ControllerActionContext
* Move the check to determine if a controller can be instantiated into the controller activator.
* Move logic for disposing controllers into the controller activator and make release on the
controller factory delegate into the activator.
* Changed release methods to take in a controller context.