我的代码使用 .apsx 页面和以下代码在选项卡/新窗口中打开 PDF:
string fileName = GetFileName(so);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "inline; filename=" + fileName);
Response.BinaryWrite(pdfStream);
在浏览器中为 PDF 选择保存选项时,保存对话框中的文件名未在 IE 中正确填充 (11);它仍在使用页面名称。 Chrome 和 FF 也像我期望的那样工作(使用提供的文件名作为建议名称)。
此外,当我将内容配置更改为附件而不是内联时,IE 与 Chrome 和 FF 的工作方式相同。他们都使用文件名作为建议的保存名称。
我是否缺少有关如何使用内联功能的内容?
最佳答案
您是否尝试将内联更改为附件? Response.AddHeader("content-disposition", "attachment; filename="+ fileName);
关于c# - IE11 不尊重内容处置的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30465589/