title: IIS7 - Specifying content-length header in ASP causes "connection reset" error
body: <p>I'm migrating a series of websites from an existing IIS5 server to a brand new IIS7 web server.  One of the pages pulls a data file from a blob in the database and serves it to the end user:</p>
  
  <pre><code>Response.ContentType = rs("contentType")
  Response.AddHeader "Content-Disposition", "attachment;filename=" &amp; Trim(rs("docName"))&amp;rs("suffix")' let the browser know the file name
  Response.AddHeader "Content-Length", cstr(rs("docsize"))' let the browser know the file size
  </code></pre>
  
  <p>Testing this in the new IIS7 install, I get a "Connection Reset" error in both Internet Explorer and Firefox.  The document is served up correctly if the Content-Length header is removed (but then the user won't get a useful progress bar).</p>
  
  <p>Any ideas on how to correct this; whether it be a server configuration option or via code?</p>
  
  <p><strong>Edit 1:</strong> Did a bit more trial and error.  The requests will succeed if both "Enable Buffering" and "Enable Chunked Encoding" are false.  If either one is enabled the error occurs.</p>
  
  <p><strong>Edit 2:</strong> More trial and error testing; turns out that text files will work fine with the script; only binary files (images, pdfs, etc.) will fail.  Still completely clueless otherwise.</p>