I have an ASP.NET MVC web app which includes the facility for clients to upload/download documents from a folder on the server.
I'm having a problem with people uploading file names containing an ampersand character (possibly other characters too, this is the only one I've discovered so far).
The result is I'm getting javascript redirects looking something like:
window.location.href = 'MyController/DownloadDocument?filename=Dog & Cat.pdf';
which obviously doesn't work.
What's the easiest work around for something like this? Is there any way to escape the ampersand in the query string?
Use encodeUriComponent
(which will also fix the problem of the spaces, which aren't allowed in URIs)