3

我在尝试在 IE8 中下载带有分号的文件名时遇到问题。

Response.AddHeader("Content-Disposition", "attachment; filename=\"" + attachment.File.FileName + "\"");

假设 attachment.File.FileName = "Test;Test;Test.txt"

FF 3.5:它会提示您保存/打开名为“Test;Test;Test.txt”的文件。这是期望的结果。

IE8:它会提示您保存/打开名为“Test”的文件。

我需要弄清楚如何在 IE8 中获得所需的结果。

4

2 回答 2

2

您是否使用转义序列对 ; 进行了测试?(%3B) ?

Response.AddHeader("Content-Disposition", "attachment; filename=\"file%3Bfile%3B.txt\"");
于 2009-09-28T16:39:01.223 回答
-1

检查 IE 的条件并使用 URLEncoder.encode。它会起作用的。

例如。: if (isIE) { fileName = URLEncoder.encode(fileName, "UTF-8"); }

于 2012-01-18T09:28:32.230 回答