title: XMLHttpRequest fails when outgoing Content-Length exceeds 3508 bytes. Why?
body: <p><strong>UPDATE:</strong> I've moved on, not looking for an answer</p>
  
  <p><strong>UPDATE:</strong> See the last update below.</p>
  
  <p>I'm doing a POST request using JQuery's <code>jQuery.ajax()</code> function and when the outgoing <code>Content-Length</code> exceeds 3508 bytes something goes wrong and no response is returned. As long as the Content-Length remains under 3509 bytes everything will work fine. </p>
  
  <p>Here's some other things I've noticed:</p>
  
  <ul>
  <li><p>If I change the method from POST to GET everything works fine, but because a URL has a (browser-specific) maximum length I don't think I can just do this (for example the maximum length is 2,083 characters for Internet Explorer). </p></li>
  <li><p>When I do a normal non-XMLHttpRequest form POST everything works fine too (even with a Content-Length far greater than 3508 bytes).</p></li>
  <li><p>Firefox (3.6.12) will still call the success handler with data being "undefined" while Internet Explorer (8) will instead call the error handler with textStatus being "error" and errorThrown "undefined".</p></li>
  </ul>
  
  <p>Note that on the "server side" I'm running the ASP.NET Development Server and using ASP.NET MVC 1.0. </p>
  
  <p>Here's basically what I'm doing:</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "", // A resource on localhost
      // The following string results in a Content-Length of 3509 bytes
      data: "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------",
      success: function(response) {
          alert(response);
      },
      error: function(XMLHttpRequest, textStatus, errorThrown) {
          alert(textStatus + " " + errorThrown);
      },
      dataType: "json"
  });
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Here are the request headers for a failed request (there is no response): </p>
  
  <pre><code>POST /WPA/BerekenEindcijfer HTTP/1.1
  Host: localhost:4387
  User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729)
  Accept: application/json, text/javascript, */*
  Accept-Language: en-us,en;q=0.5
  Accept-Encoding: gzip,deflate
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Keep-Alive: 115
  Connection: keep-alive
  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  X-Requested-With: XMLHttpRequest
  Referer: http://localhost:4387/WPA
  Content-Length: 3509
  </code></pre>
  
  <p><strong>UPDATE:</strong> I published the application to IIS (5.1) and the problem didn't occur there and weirdly enough the problem now also doesn't occur anymore using the ASP.NET Development Server. For some reason two new headers appear in the request (though I'm not sure if they have any impact):</p>
  
  <pre><code>Pragma: no-cache
  Cache-Control: no-cache
  </code></pre>
  
  <p>I'm still baffled as to what is/was going on.</p>