title: HTML Form Data Lost On POST
body: <p>We have a very strange problem which we have yet to be able to diagnose. Our application has a number of specific ASP.NET MVC actions which fail because a required parameter is missing:</p>
  
  <pre><code>The parameters dictionary contains a null entry for parameter 'myVariable' of non-nullable type... etc
  </code></pre>
  
  <p>Each of these is some sort of HTTP POST, and thus we expect to see form data. In some cases there should be over a dozen variables.</p>
  
  <p>We use ELMAH to collect errors in the web application, and via this tool you can typically see the actual form data which is posted during a request which fails. However in these specific errpr when there should be several variables the entire form is missing!</p>
  
  <p>We simply cannot reproduce this on-demand. However with the volume of traffic in our application we see these errors several dozen times a day. Users cannot reproduce the error either, and trying the same action in the web browser works a second time.</p>
  
  <p>We're also not 100% sure where the data is lost. Is it in the web browser? Inside the IIS pipeline? Or is it ASP.NET MVC which dumps it? Totally unsure.</p>
  
  <p>If anyone can help us troubleshoot and/or diagnose this problem it would be greatly appreciated.</p>
  
  <p>Update 1: We've discovered that the content length as specified in the HTTP Headers is of a size that suggests that there is some content in the request. However the forms collection on the request is empty (as per ELMAH). So we've added some additional logging to trace the actual length of the content received and the content itself.</p>
  
  <p>Update 2: We have discovered that while the CONTENT_LENGTH HTTP Header is of the correct size (for a similar requests), the content itself is missing. The stream contains 0 bytes. </p>
  
  <p>We've also be able to narrow down the problem to Internet Explorer, we can't seem to get it to happen with other browsers.</p>
  
  <p>We've been able to sometimes recreate the problem by causing several overlapping AJAX requests in the browser, and then either refreshing or redirecting. It's almost as if Internet Explorer is closing the connection before completely writing out the stream buffer.</p>
  
  <p>We have not been able to trace this with Fiddler. Using Fiddler, it appears it is impossible to recreate the specific situation.</p>
  
  <p>Update 3: Everything we've seen can be explained by this: <a href="https://stackoverflow.com/questions/4796305/why-does-internet-explorer-not-send-http-post-body-on-ajax-call-after-failure">Why does Internet Explorer not send HTTP post body on Ajax call after failure?</a></p>