views:

24

answers:

1

Hi,

I have an action method that returns a FileStreamResult, the download works fine, the problem is that although I set the FileDownloadName property of the result object, some of the files are downloaded with another name (specifically the last part of the address of the page I'm working on. e.g. in the page "http://localhost:5479/Items/Edit/277" it will download a file called "277").

This happens when the name of the file contains special chars (e.g. "San José.jpg"), but it works just fine when the name doesn't have such chars (e.g. "San Jose.jpg").

So, my question is, how do I allow the user to download a file with special chars in its name? or, if it isn't possible, is there a method that removes all the special chars from a string or do I have to create one?

Thanks

+1  A: 

Actually I just found a way to fix this.

Basically what I have to do is use the HttpUtility.UrlEncode method to convert the name of the file, when the file is downloaded it will get almost the same name as the original file (the difference being the spaces replaced with a plus (+) sign).

Hope this helps someone else.

willvv