I have a web application that streams a PDF file on a click event, it works fine in IE, Firefox, and Safari but in Chrome it never download. The download just reads "Interrupted". Does Chrome handle streaming differently? My code looks like:
this.Page.Response.Buffer = true;
this.Page.Response.ClearHeaders();
this.Page.Response.ClearContent();
this.Page.Response.ContentType = "application/pdf";
this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);
Stream input = reportStream;
Stream output = this.Page.Response.OutputStream;
const int Size = 4096;
byte[] bytes = new byte[4096];
int numBytes = input.Read(bytes, 0, Size);
while (numBytes > 0)
{
output.Write(bytes, 0, numBytes);
numBytes = input.Read(bytes, 0, Size);
}
reportStream.Close();
reportStream.Dispose();
this.Page.Response.Flush();
this.Page.Response.Close();
Any suggestions as to what I might be missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…