【问题标题】:Cannot open xls file in IE无法在 IE 中打开 xls 文件
【发布时间】:2011-03-05 11:46:30
【问题描述】:

我们有 JSF Web 应用程序,它生成 XLS 文件并为用户提供指向这些文件的链接。
如果通过 HTTP 访问此文件,一切正常。
但 IE(8) 无法通过 HTTPS 打开/保存此 xls 文件。
有以下错误信息:

Internet Explorer cannot download ...466088C5C313F92808BDB0AFF3447 from testhost.

Internet Explorer was not able to open this Internet site.  The requested site is either unavailable or cannot be found.  Please try again later.

我可以在 Firefox 和 Chrome 中通过 HTTPS 打开同一个文档。
IE可能有什么问题?

标题:

HTTP/1.1 200 OK
Date: Fri, 18 Jun 2010 14:45:42 GMT
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
X-UA-Compatible: IE=EmulateIE7
Last-Modified: Fri, 18 Jun 2010 14:45:11 GMT
Cache-control: max-age=0, no-store, no-cache
Pragma: no-cache
Expires: 0
Content-Type: application/vnd.ms-excel
Content-Length: 6656
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive

【问题讨论】:

    标签: internet-explorer jsf internet-explorer-8 https


    【解决方案1】:

    根据http://support.microsoft.com/kb/316431,您应该删除您使用的任何这些 HTTP 标头:

    Pragma: no-cache
    Cache-control: no-cache,max-age=0,must-revalidate
    

    【讨论】:

    • 缓存控制: max-age=0, no-store, no-cache Pragma: no-cache
    • @Vladimir Bezugliy:删除那些。
    【解决方案2】:

    最可能的原因是 http 响应头,我们必须专门为 ssl 下的 xls 文件配置它

    Expires: Mon, 26 Jul 1997 05:00:00 GMT
    Last-Modified: Fri, 18 Jun 2010 16:22:07 GMT
    Cache-Control: cache, must-revalidate
    Pragma: public
    

    用于缓存控制 和

    Content-Type: application/vnd.ms-excel
    Content-Disposition: attachment; filename="ExcelDownload.xls"
    Content-Transfer-Encoding: binary
    Content-Length: <fileSize>
    

    内容

    关键条目是 Pragma: public

    【讨论】:

      【解决方案3】:

      您是否将缓存控制设置为无缓存?我遇到了类似的问题。详情请见this question and answer

      【讨论】:

      • 缓存控制: max-age=0, no-store, no-cache Pragma: no-cache
      • 删除无缓存,看看会发生什么
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-29
      • 1970-01-01
      • 2019-06-14
      • 1970-01-01
      • 1970-01-01
      • 2021-06-13
      • 1970-01-01
      相关资源
      最近更新 更多