[英]Download a zip or a pdf doesn't work on IE8
我在項目中遇到了問題。 我的頁面上有兩個按鈕,一個用於下載pdf,另一個用於下載zip。 這些下載可在除IE8之外的所有瀏覽器上運行(IE9可以運行)。
在IE8中,有一條消息,提示“為了幫助保護您的安全,...”。 當我單擊“下載此文件”時,瀏覽器刷新頁面,而我所做的一切都丟失了。 但是,當我再次嘗試下載文件時,瀏覽器讓我開始下載。
有一個截圖:
有我的代碼:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (IsPostBack)
return;
if (Request.QueryString["outputpdf"] == "1" && !string.IsNullOrEmpty(PdfReportFilePath))
{
OutputPdfFile(PdfReportFilePath);
PdfReportFilePath = string.Empty;
Response.End();
}
if (Request.QueryString["outputexport"] == "1" && !string.IsNullOrEmpty(RxMapSession.ExportedFilePath))
{
OutputExport(RxMapSession.ExportedFilePath);
RxMapSession.ExportedFilePath = RxMapSession.ExportedFileName = string.Empty;
Response.End();
}
initChart();
}
private void OutputExport(string exportedFilePath)
{
Response.ContentType = "application/zip";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(exportedFilePath));
Response.WriteFile(exportedFilePath);
}
private void OutputPdfFile(string reportFullPath)
{
string fileName = reportFullPath.Split('\\').Last();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.WriteFile(reportFullPath);
Response.End();
}
您有任何想法為什么我在IE8上有此問題嗎?
嘗試這個
轉到工具→Internet選項
轉到高級選項卡
選中“允許活動內容在我的電腦上的文件中運行”。
保存設置並關閉所有IE窗口,然后重新啟動IE。
要么
轉到工具→Internet選項
單擊安全選項卡,然后單擊安全區域受信任的站點。
單擊網站。
該網站應顯示在“將該網站添加到區域”字段中。
單擊添加。
單擊關閉,然后單擊確定。
關閉所有IE窗口,然后重新啟動IE。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.