Closed Eilon closed 6 years ago
Thanks for contacting us, @fanslead.
Model binding validation doesn't throw automatically for non-api controllers. If you would like to get that behavior, you can decorate your controller with [ApiController]
attribute.
@dougbu, can you please advice whether the behavior of setting the model to null even when parts of it have failed to validate is the expected behavior or not? Thanks!
Thank you for your reply. I decorate my controller with [ApiController] attribute can get an exception info correctly.
From @fanslead on Friday, 12 October 2018 07:31:38
Environment: .net core sdk version 2.1.403 and Microsoft.AspNetCore.App version 2.1.5 A model like this You have an api need this model parameter from body and Content-Type is application/json. Normally we will send the json data like But if we make a mistake about the type of one of the fields, the model parameter we received in back-end will be null and without throw any exception. I think even if no exception is thrown, the model parameter should not be null, keep the data of correct field at least.
Copied from original issue: aspnet/AspNetCore#3618