Semicolon in Content-Disposition filename

I have a problem loading semicolon file names in IE8.

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

Assuming attachment.File.FileName = "Test; Test; Test.txt"

FF 3.5: it offers you to save / open a file with the name "Test; Test; Test.txt". This is the desired result.

IE8: it suggests you save / open a file called "Test".

I need to figure out how to get the desired result in IE8.

+3
source share
2 answers

You did the test using the escape sequence for; (% 3B)?

Response.AddHeader("Content-Disposition", "attachment; filename=\"file%3Bfile%3B.txt\"");
+2
source

check condition for IE and use URLEncoder.encode. He will work.

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

-1
source

Source: https://habr.com/ru/post/1718723/


All Articles