New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HttpContent.Read* methods return empty content when using parameter binding in Web API controller #150
Comments
From @naamunds on September 8, 2016 21:4 This StackOverflow answer suggests that in Web API the request content can only be read once by design, but I was able to successfully invoke the Request.Content.Read* methods multiple times within a controller method when not using parameter binding, so it appears that the issue is specific to parameter binding. |
From @davidfowl on September 12, 2016 6:20 This doesn't have anything to do with ASP.NET Core does it? |
From @naamunds on September 12, 2016 16:32 @davidfowl I encountered this issue in ASP.NET Web API 2.x (not Core). Would https://github.com/aspnet/AspNetWebStack instead be the appropriate place to log this issue? |
That repo is not yet public -- we're working on the infrastructure. File issues at https://aspnetwebstack.codeplex.com/ until that changes. |
From @naamunds on September 12, 2016 19:36 I see. I've logged https://aspnetwebstack.codeplex.com/workitem/2315 for this issue. |
From @mahmoud690 on April 11, 2018 11:53 I have the same error. I use the latest version of WebApi (5.2.4) but the problem still exists. |
Reopened in preparation for move to aspnet/AspNetWebStack Side note: CodePlex is now in archived state. We never saw https://aspnetwebstack.codeplex.com/workitem/2315 |
Any Web API parameter that is a complex type is automatically bound from that request body. That consumes the body, leaving the stream positioned at the end. It may be possible to rewind the request stream. Your application will probably need to call Either way @mahmoud690 and @naamunds we thank you for your feedback. We're closing this issue as the behaviour discussed is by design. |
From @naamunds on September 8, 2016 20:55
Repro steps
Request.Content.ReadAsStringAsync
.application/json
content to the URI handled by the controller method.Expected behavior
The content returned by the
HttpContent.Read*
method represents the actual request's content.Actual behavior
The content returned by
HttpContent.Read*
is empty.Copied from original issue: aspnet/Mvc#5258
The text was updated successfully, but these errors were encountered: