【问题标题】:Download a zip or a pdf doesn't work on IE8下载 zip 或 pdf 在 IE8 上不起作用
【发布时间】:2013-02-05 23:13:14
【问题描述】:

我在我的项目中遇到了一个问题。我的页面中有两个按钮,一个用于下载 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 上会出现这个问题吗?

【问题讨论】:

  • 这是 XP 上 IE8 的客户端“问题”。你不能在你的代码中做任何事情。一些用户也会遇到这个问题。
  • 我在 Windows Server 2008 上试过这个。我不知道我客户的操作系统。
  • 服务器可能启用了“Internet Explorer 增强安全性”..
  • 不,服务器已关闭

标签: c# asp.net internet-explorer-8 download


【解决方案1】:

试试这个

  1. 转到工具 → Internet 选项

  2. 转到高级选项卡

  3. 选中“允许活动内容在我的电脑上的文件中运行”。

  4. 保存设置并关闭所有 IE 窗口并重新启动 IE。

  1. 转到工具 → Internet 选项

  2. 单击“安全”选项卡,然后单击安全区域受信任的站点。

  3. 点击站点。

  4. 该网站应显示在“将此网站添加到区域”字段中。

  5. 点击添加。

  6. 单击关闭,然后单击确定。

  7. 关闭所有 IE 窗口并重新启动 IE。

【讨论】:

  • 抱歉,这些都不起作用。我尝试了第一个,然后是第二个,并且同时尝试了两个,但它不起作用。此外,我们的客户无法更改他们的安全政策。
  • 保护模式也关闭了。
  • 我找到了解决方案。当您将您的网站放入受信任的站点时,您必须将级别设置为中低。我离开了中等级别,它仍然提示下载文件。在中低级别,下载文件。再次感谢您的回答。
猜你喜欢
  • 1970-01-01
  • 2013-04-03
  • 1970-01-01
  • 2019-03-04
  • 1970-01-01
  • 2014-04-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多