小编Rag*_*van的帖子

IE中的Content-Disposition内联文件名问题

我在浏览器中使用aspx页面在API中显示pdf.

使用Chrome/Firefox保存pdf时,请从中获取文件名
header("Content-Disposition", "inline;filename=xyz.pdf")

但是在使用IE保存pdf时,它不会从中读取文件名
header("Content-Disposition", "inline;filename=xyz.pdf").
相反,它采用aspx名称.

技术细节

我有一个xyz.aspx页面.xyz.aspx页面将调用文档的API.然后,来自API的下载文档将转移到带内联的浏览器以显示pdf文档.我将响应头设置如下并写入文件字节.

            HttpContext.Current.Response.ClearHeaders();

            Response.AddHeader("Content-Disposition", "inline;filename=\"" + Name + "\"");

            HttpContext.Current.Response.ContentType = "application/pdf";
Run Code Online (Sandbox Code Playgroud)
  • 问题:

    在IE中保存打开的pdf时,需要xyz.aspx而不是标题中的名称.

  • 需求:

    在使用IE保存pdf时,需要使用pdf名称进行保存.

我搜索了这么多,因为每个人都告诉它的IE行为.我希望有人知道解决方案.

注意:我必须在浏览器中显示pdf然后保存.不要使用"附件"下载

提前致谢.

response-headers

5
推荐指数
1
解决办法
8176
查看次数

标签 统计

response-headers ×1