Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We've reverted to using request.InputStream in Web API due to this problem (<a href="http://aspnetwebstack.codeplex.com/SourceControl/changeset/9c76bb9090490541a453fcead75485ea50b88022" rel="noreferrer">commit 9c76bb9090490541a453fcead75485ea50b88022</a>).</p> <p>JimmiTh's answer correctly notes a discrepancy between the initial release notes and the implementation. As implied in the <a href="http://msdn.microsoft.com/en-us/library/system.web.readentitybodymode.aspx" rel="noreferrer">later documentation mentioned above</a> (though it is not particularly clear), request.GetBufferlessInputStream(), request.GetBufferedInputStream() and request.InputStream (along with Form, Files, etc.) are three mutually exclusive methods of request body access.</p> <p>It appears that, contrary to the <a href="http://www.asp.net/web-pages/overview/whats-new/whats-new-in-aspnet-45-and-visual-web-developer-11-developer-preview" rel="noreferrer">initial release notes</a>, request.GetBufferedInputStream() is not currently usable unless no other callers for the same request use any of InputStream, Form, Files, etc. I'm also following up to see if something better can be done compatibility between these two methods.</p> <p>David</p> <p>An update after talking with the product team: Calling request.GetBufferedInputStream() or request.GetBufferlessInputStream() means "I'm handling the stream explicitly myself; take me into advanced mode where automatic stream processing is disabled." However, in the case of buffered only, the members that normally rely on automatic stream processing (Form, Files, InputStream, etc.) are re-enabled after the buffered stream has been fully read.</p> <p>So, as the exception message hints, touching any of those properties before finishing reading the stream will fail:</p> <pre><code>public ActionResult Index() { Request.GetBufferedInputStream(); var ignore = Request.InputStream; return View(); } </code></pre> <p>But doing so after finishing reading the stream will succeed:</p> <pre><code>public ActionResult Index() { var stream = Request.GetBufferedInputStream(); new StreamReader(stream).ReadToEnd(); var ignore = Request.InputStream; return View(); } </code></pre> <p>The documentation isn't particularly clear here; I'll ask the product team if they can improve it.</p> <p>We're planning on switching back to GetBufferedInputStream in Web API; we'll just make sure it plays better with MVC in terms of when this call happens relative to consuming the stream and MVC executing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload