【发布时间】:2011-12-20 22:27:00
【问题描述】:
我有一个包含显示 pdf 的 iframe 的 aspx 页面(我有在 iframe 中显示 pdf 的 ashx 处理程序),我还有一个下载按钮,它的 onclick 流与浏览器不同的 pdf 作为附件。 下载到浏览器代码:(这是在 ashx 处理程序中)
byte[] bytes = // get byte array from table
Response.Buffer = false;
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
// [optional]
Response.AddHeader(
"Content-Disposition",
string.Format("attachment; filename={0}", attachmentName)
);
Response.OutputStream.Write(bytes, 0, bytes.Length);
Response.End();
此代码工作正常,但是在将此响应发送到浏览器后,我的 iframe 变为空白,我必须刷新页面才能再次看到它。我尝试了大多数解决方案
但它们都不起作用。 iframe 在 chrome 和 FF 中表现良好。 注意:如果我使用 asp:hyperlink 下载东西到我的 ashx 并设置 target="_blank" 它在 IE 中工作正常,但我需要一些服务器端处理,因此我不能使用这种方法。
【问题讨论】:
-
你用的是什么版本的IE?你试过什么版本?
-
我用的是 IE9,我试过 IE 7,8。