Question

I have a problem trying to download filenames with a semicolon in them in IE8.

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

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

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

IE8: It prompts you to save/open the file with the name "Test".

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

Was it helpful?

Solution

Did you made a test using the escape sequence for ; (%3B) ?

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

OTHER TIPS

check the condition for IE and use URLEncoder.encode. It will work.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top