Response.AddHeader无法在IE中运行

时间:2013-05-24 02:12:43

标签: c# asp.net internet-explorer response.addheader

使用Response.AddHeader时遇到问题。 Firefox和Chrome工作正常(它们显示弹出窗口并下载文件),但不在IE中,它只打开一个空白弹出窗口而不执行任何操作,例如下载文件或显示提示。弹出标题是“-- webpage dialog”。

我的代码如下:

byte[] bRpt = ExportReportYoStream(rptMain, ExportFormatType.Excel);
Response.ClearHeaders();
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment;filename=Test Document.xls");
Response.BinaryWrite(bRpt);
Response.Flush();
Response.End();

我也尝试过很多改动:

Response.ContentType = "application/Save";
Response.ContentType = "application/octet-stream";
我可以在互联网上找到更多信息。

1 个答案:

答案 0 :(得分:0)

好吧..当我试了一天并把它弄出来时,这个问题就解决了。

简单,即不允许在弹出页面中使用“Response.AddHeader”(我试过ie8-10)。 我不知道为什么但是在crome和ff上工作。

如果有人知道为什么那样的行为,我很欣赏..

感谢,