I have a HttpHandler
that returns a large chunk (~400k lines) of XML. For some reason the data is being corrupted on its way out. Here's a simple test case:
public class SimpleTestCase : HttpHandlerBase
{
public override bool IsReusable
{
get { return false; }
}
protected override void HandleRequest(HttpContext context)
{
context.Response.ContentType = "application/xml";
context.Response.Write("<?xml version=\"1.0\"?>" + Environment.NewLine);
for(var i = 0; i < 400010; i++)
{
context.Response.Write("<amount>5</amount>" + Environment.NewLine);
}
}
}
When I look at the result I see about 60 of the 400,010
instances where this is written:
<amount>5amount>
Notice that the opening portion of the closing tag (</
) is missing. Why is the Response
stream being corrupted? And more importantly, how do I prevent it?
Update: In case it is relevant, Visual Studio 2013, IIS Express, .NET 4.5
<amount>6</amount>
to ensure browser wasn't caching. – Philip Pittle Jun 4 at 14:38