【发布时间】:2011-09-13 05:54:52
【问题描述】:
我有一个网络应用程序,可以在点击事件上流式传输 PDF 文件,它在 IE、Firefox 和 Safari 中运行良好,但在 Chrome 中它从不下载。下载只是显示“中断”。 Chrome 处理流媒体的方式不同吗?我的代码如下:
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();
关于我可能缺少什么的任何建议?
【问题讨论】:
标签: asp.net google-chrome mime-types