Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 21, 2012 04:55 PM by Kiran Challa
Mar 21, 2012 04:42 PM|LINK
I have a POST method in my controller that looks like:
public HttpResponseMessage<SubmitFeedResponse> Post(AmazonEnvelope envelope)
The AmazonEnvelope is an object that is deserialized from the POST content. Inside this controller I would like to read the content again so I start a task:
Task contentTask = this.ControllerContext.Request.Content.ReadAsStreamAsync().ContinueWith(a =>
But I set a breakpoint and it appears that this task never returns. I never break into the 'ContinueWith' part. I have also tried this without attaching the debugger to w3wp.exe but I get the same results on the client, namely an 'InternalServerError'. Would there be a reason that I cannot read this content twice? Can I change (should I) the signature like?
public HttpResponseMessage<SubmitFeedResponse> Post()
Any suggestions as to why this is not working and what I may have misunderstood?
Mar 21, 2012 04:55 PM|LINK
Assuming you are using the ReadContentPolicy as SingleObject, the ModelBinding step uses the formatters to deserialize the request's content in order to build the Action's parameters.
In this case, the model binding uses the formatters to populate the 'envelope' parameter of the Post method.
Our default formatters currently close the request stream after reading it. This is a known issue that we are planning to fix for the next release.