I use the following code to send a .zip file to a customer, it works great for files around 60-80 Mb but when I try with larger files (300 Mb) customers report that the browser (both IE and FFX) just stops download progress after a few minutes (around (80Mb)) and nothing more happens.
I wonder if there could be a setup issue with IIS that stops the request handling thread to execute after a few minutes or if there is anything wrong with my code.
I could obviously find other ways to deliver .zip files but this issue is bothering me a bit and I want to get it working.
The code:
Response.ContentType = "application/zip";
Response.AddHeader("Content-Disposition", "attachment; filename=" + "hands.zip");
var fi = new FileInfo(dld.Path);
Response.AddHeader("Content-Length", fi.Length.ToString());
const int buffercnt = 50000;
var buffer = new byte[buffercnt];
using (var br = new BinaryReader( new StreamReader(dld.Path).BaseStream))
{
int read = br.Read(buffer, 0, buffercnt);
while(read != 0)
{
Response.OutputStream.Write(buffer, 0, read);
read = br.Read(buffer, 0, buffercnt);
Response.Flush();
}
}
Response.Close();
Response.End();