【问题标题】:Chrome appending -- to end of filenameChrome 将 -- 附加到文件名的末尾
【发布时间】:2017-10-06 14:22:24
【问题描述】:
string fileName = "test.txt";
byte[] docBytes = getDocumentBytes();

return File(docBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);

这会在 Firefox 和 Edge 上返回一个名为“test.txt”的文件,但在 Chrome 上它会返回一个名为“test.txt--”的文件。 有谁知道它为什么会这样?有没有办法在代码中解决这个问题?

【问题讨论】:

    标签: c# asp.net-mvc google-chrome


    【解决方案1】:

    嗯,这很难找到。

    Chrome 将文件名末尾的空格转换为“-”。

     return File(docBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName.Trim());
    

    修剪解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2017-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-11
      • 1970-01-01
      • 2015-04-09
      • 2013-05-31
      • 2010-09-23
      相关资源
      最近更新 更多