Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Issue: WebAPI invokes the action with default-valued parameters when content-type is not specified [281]

$
0
0
public void Post([FromBody]string item)
{
}

Incoming request with a body but no content-type hits the action with a null string parameter and a valid model state. I would expect one of two behaviors:

1) First formatter (e.g. JSON) gets selected to read the body and model state gets an error if deserialization fails.
2) Server sends back a bad request error saying there's no content type

Here's what the HTTP spec says:

Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its content and/or the name extension(s) of the URI used to identify the resource. If the media type remains unknown, the recipient SHOULD treat it as type "application/octet-stream".
Comments: We should return a 4xx if the request does not have a media type in this case.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>