You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a Polymorphic JsonConverter on a list of objects in a request to an Asp.Net Core Web app ModelStateValidation for properties of the objects in that list lose their context. For example if i have an object Person and that object has a property Friends which is a List, if I set the Gender enum to an invalid enum value when using JsonConverter i get a response like:
{
"gender": [
"The input was not valid."
]
}
but if you take the JsonConverter off of the model you get:
{
"friends[0].gender": [
"The input was not valid."
]
}
I tried to place JsonConverters in the AddJsonOptions extension method on IServiceCollection, or directly on the model with the same result, not that I expected it to change.
To Reproduce
Using this version of ASP.NET Core 2.1 or 2.2
Open the solution contained inside of the Stuffies.zip file.
You'll see that the context of the response exists in the response: friends[0].gender
Now go into the ValuesController and uncomment the Attributes on the Person class
Debug again and do the same Post
See the differences in the previously mentioned responses between when you add or remove the Attributes from the Person class. Now the response will have : gender without the context.
Expected behavior
I expected the response to have the context on the ModelState error.
Screenshots/Sample Project
If applicable, add screenshots to help explain your problem. Stuffies.zip
The text was updated successfully, but these errors were encountered:
Eilon
added
the
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
label
Dec 13, 2018
Hi. It looks like this is a question about how to use ASP.NET Core. While we do our best to look through all the issues filed here, to get a faster response we suggest posting your questions to StackOverflow using the asp.net-core-mvc tag.
Thank you for contacting us. Due to no activity on this issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue.
Description
When using a Polymorphic JsonConverter on a list of objects in a request to an Asp.Net Core Web app ModelStateValidation for properties of the objects in that list lose their context. For example if i have an object Person and that object has a property Friends which is a List, if I set the Gender enum to an invalid enum value when using JsonConverter i get a response like:
I tried to place JsonConverters in the AddJsonOptions extension method on IServiceCollection, or directly on the model with the same result, not that I expected it to change.
To Reproduce
using the following json:
Expected behavior
I expected the response to have the context on the ModelState error.
Screenshots/Sample Project
If applicable, add screenshots to help explain your problem.
![stuffies](https://user-images.githubusercontent.com/32906437/49656041-ee04bf80-fa01-11e8-8c0d-ea593812a4d0.PNG)
Stuffies.zip
The text was updated successfully, but these errors were encountered: