Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between ContentDispositionHeaderValue.FileName and ContentDispositionHeaderValue.FileNameStar

We have a .Net Web application where the user can download files. The file name the files can have may contain danish characters æ, ø and å and maybe some other characters of some foreigh language.

We use the class HttpResponseMessage to send the file where ContentDispositionHeaderValue is initialized as an "attachment".

However assigning the

FileName 

property does not work in IE for the Danish characters but works if I assign the file name to

FileNameStar

where the filename gets automatically encoded to the right format.

So this works:

Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
    FileNameStar = "filename with æ ø and å"
};

I can however not find any documentation as to why it is automatically encoded, and which browsers support this feature.

Searching the internet, gives suggestions that I should url encode the string before assigning it to FileNamestar property. But this is not necessary, as I can see in the http trace that it is encoded correctly.

Do all major browsers support this? And can I be sure that the filenames are encoded correctly?

Thanks Jihad

like image 712
Jihad Haddad Avatar asked Nov 18 '16 23:11

Jihad Haddad


1 Answers

Taken from here:

The FileNameStar property uses IETF RFC 5987 encoding. The FileName and FileNameStar properties differ only in that FileNameStar uses the encoding defined in IETF RFC 5987, allowing the use of characters not present in the ISO-8859-1 character set.

like image 130
Jonas Avatar answered Sep 25 '22 12:09

Jonas