We are implementing long running process to download database content as xml with asp.net 3.
Total document generation time is about 3-5 minutes and we want to respond with first byte as soon as possible. We have overridden System.Web.Mvc.FileResult
and are trying to do something like:
protected override void WriteFile(HttpResponseBase response)
{
Stream outputStream = response.OutputStream;
byte[] header = xmlExportService.XmlHeader();
response.Flush();
outputStream.Write(header, 0, header.Length);
response.Flush();
//// some long running generation here
}
On local iis under windows 7 I am gatting Save File dialog in browser. On production, windows server 2008 R2 there is no dialog until whole file is generated.
Any ideas?
Not sure if this helps anyone, but Response.Flush will not "work" if you have HTTP compression enabled. We enabled dynamic compression on our servers and the call to Response.Flush would just hang. After some research, it has to do with the fact that the server is waiting for all the output so it can "compress it and send it".
Since we are using MVC, I am considering using an attribute to dynamically control if compression is enabled for non-static pages. For now, we just got rid of the Response.Flush call in our Views.
Have you seen this postings? Same questions, accepted answers, might be of help?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With