Royi Namir
Royi Namir

Reputation: 148664

Internet explorer shows gibberish for save/open file?

I have this C# code which downloads a file from server :

 public static void DownloadBinaryFile(byte[] _ByteArray, string fullfileName)
        {
             fullfileName = "רועי.pdf"; //"Royi.pdf" in hebrew
             System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + fullfileName);
             System.Web.HttpContext.Current.Response.BinaryWrite(_ByteArray);
             System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
             System.Web.HttpContext.Current.Response.Flush();
             System.Web.HttpContext.Current.Response.End();
        }

Notice that filename has a fixed value ( for testing).

When I click a button :

enter image description here

I DO see in FIDDLER the right name :

enter image description here

And Chrome does shows the right filename to save :

enter image description here

But Internet explorer shows gibberish :

enter image description here

Additional Information :

IE 11 , windows 7 64bit , Edge :

enter image description here

Page encoding :

enter image description here

Question:

Why does the filename shown as gibberish and how can I fix it ?

Upvotes: 1

Views: 816

Answers (1)

Julian Reschke
Julian Reschke

Reputation: 42045

Because you can't use non-ASCII characters inside Content-Disposition without additional escaping. See http://greenbytes.de/tech/webdav/rfc6266.html#disposition.parameter.filename.

Upvotes: 1

Related Questions