ASP plain text file response is cut short
<p>I have an ASP web forms page with a button. On postback the button sends some XML content back to the user as a file. It has been working however in one case with a string with a length of 16759 the downloaded file has been cut short by 10 bytes. Both Chrome and Firefox have exhibited the same behaviour.</p>

<p>The solution has been to change the content-type from "text/xml" (I also tried "text/plain") to "application/octet-stream". However I would like to understand why the other content-types behave in this way. </p>

<p>My code is as follows. (I've played around with a few different methods and they did not change anything)</p>

<pre><code>HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "text/plain";
HttpContext.Current.Response.AddHeader("Content-Length", content.Length.ToString());
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=\"test.txt\"");
HttpContext.Current.Response.Write(content);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
</code></pre>
