【问题标题】:Internet explorer does not download file with Unicode name through Jquery FileDownloadInternet Explorer 不通过 Jquery FileDownload 下载具有 Unicode 名称的文件
【发布时间】:2018-11-01 05:36:51
【问题描述】:

我正在尝试下载一个文件,该文件通过在客户端使用来自 jquery 的 fileDownload 从服务器检索。 MVC 控制器返回一个 FileDownloadResult 类型的简单对象:

public sealed class FileDownloadResult : IHttpActionResult, IDisposable
{
        private readonly MemoryStream _dataStream;
        private readonly string _fileName;

        ... various methods() ...
}

我要下载的文件名为:FRISS_db_DiagramЁФ。 在谷歌浏览器上它工作正常,即使文件是 unicode,文件也会以正确的文件名下载。 在 Internet Explorer 上,Content-disposition 标头显示为文件名:

=?utf-8?B?RlJJU1NfZGJfRGlhZ3JhbdCB0KQucG5n?="

因此,文件以这个损坏的名称下载。如何确保使用正确的编码?

【问题讨论】:

    标签: jquery google-chrome internet-explorer unicode encoding


    【解决方案1】:

    在此处找到解决方案 (How do I encode a file name for download?)

    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename= " + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-29
      • 2014-12-10
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 2022-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多