views:

31

answers:

2

I use url rewriting and one of my urls is /blah/file ILLEGAL CHARS.jpg

ILLEGAL CHARS are names not valid on windows such as * and may confuse servers even after escaping such as ? and /.

I know i still cant save filenames as / and ? but certain characters i would like to let through. How can i give a new filename when the user right clicks and selects save as?

i'm using asp.net

+2  A: 

Adding a content-disposition attachment header to the document will allow you to specify an alternate filename. This will have the added side effect of prompting the user to download automatically if they navigate to this file.

Response.AppendHeader("content-disposition", "attachment; filename='MyFile.jpg'");
MisterZimbu
+1  A: 

The easiest thing to do is to ensure your URLs do not have illegal characters in the first place.

If you are using URL rewriting, you should already have a way to strip/replace the illegal characters.

Otherwise, the browser is responsible for taking the URL and figuring out the filename, often with poor results.

Jeff Meatball Yang
+1, this may be more trouble then it worth. but i now know to do it
acidzombie24