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
We can see that we intend that the Default property be rendered in the request JSON as a field with name "d".
When this request is sent, because it is a GET request, the value of Default will be converted to a query like this: /avatar/ahash?d=adefault
This is all well and good.
Now, in our web host, the handler is defined like this:
Note the use of [AsParameters] on the request DTO object.
When our Host receives the request: /avatar/ahash?d=adefault we are expecting the Default property of the GravatarGetImageRequest request DTO to be populated by the value of the d parameter in the query, because of the existence of the [JsonPropertyName] attribute on that property.
But this is not the case.
Instead the `Default' parameter is unpopulated once the request is handled.
In fact the ASPNET runtime will throw an exception if the Default property is declared as required instead of nullable, since the value is not populated by the request pipeline.
So there is something in the ASPNET pipeline that is ignoring the [JsonPropertyName] attribute
The text was updated successfully, but these errors were encountered:
We can define a request DTO like this:
We can see that we intend that the
Default
property be rendered in the request JSON as a field with name"d"
.When this request is sent, because it is a GET request, the value of
Default
will be converted to a query like this:/avatar/ahash?d=adefault
This is all well and good.
Now, in our web host, the handler is defined like this:
Note the use of
[AsParameters]
on the request DTO object.When our Host receives the request:
/avatar/ahash?d=adefault
we are expecting theDefault
property of theGravatarGetImageRequest
request DTO to be populated by the value of thed
parameter in the query, because of the existence of the[JsonPropertyName]
attribute on that property.But this is not the case.
Instead the `Default' parameter is unpopulated once the request is handled.
So there is something in the ASPNET pipeline that is ignoring the
[JsonPropertyName]
attributeThe text was updated successfully, but these errors were encountered: