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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With