gpt4 book ai didi

c# - Internet Explorer 在保存/打开文件时显示乱码?

转载 作者:可可西里 更新时间:2023-11-01 17:35:45 25 4
gpt4 key购买 nike

我有这个从服务器下载文件的 C# 代码:

 public static void DownloadBinaryFile(byte[] _ByteArray, string fullfileName)
{
fullfileName = "רועי.pdf"; //"Royi.pdf" in hebrew
System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + fullfileName);
System.Web.HttpContext.Current.Response.BinaryWrite(_ByteArray);
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
}

请注意文件名有一个固定值(用于测试)。

当我点击一个按钮时:

enter image description here

我确实在 FIDDLER 中看到了正确的名称:

enter image description here

并且 Chrome 确实显示了要保存的正确文件名:

enter image description here

但是 Internet Explorer 显示乱码:

enter image description here

附加信息:

IE 11、windows 7 64 位、边缘:

enter image description here

页面编码:

enter image description here

问题:

为什么文件名显示为乱码,我该如何解决?

最佳答案

因为如果不进行额外的转义,就不能在 Content-Disposition 中使用非 ASCII 字符。参见 http://greenbytes.de/tech/webdav/rfc6266.html#disposition.parameter.filename .

关于c# - Internet Explorer 在保存/打开文件时显示乱码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32089191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com