Async minimal route handlers don't serialize child members #39856
Labels
area-web-frameworks
*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
bug
This issue describes a behavior which is not expected - a bug.
The issue is best demonstrated with code. The response bodies for each route handler are written as comments.
This shows an inconsistency in how returned objects are serialized in async methods that return a
Task<Parent>
orValueTask<Parent>
vs non-async methods that returnParent
when the runtime type is a child type.The non-async route handler has the right behavior because it results in a call to
WriteAsJsonAsync<object>(...)
instead ofWriteAsJsonAsync<Parent>(...)
which is what gets called in the async case. See https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-polymorphismThe text was updated successfully, but these errors were encountered: