I'm running IIS 7 web server and getting an error 404 when trying to download a file with a # symbol anywhere in the file name.

http://www.server.com/files/my#filename.doc <-- does not download leads to 404 error.

If I remove the # symbol it works fine.

Can anyone suggest why this is happening and if there's a workaround?



Are you saying that the # is present in the filename itself?

The # is a meaningful character in the URL scheme (see RFC 3986). It separates the url path from the fragment id.

It could be that you will need to escape the octothorpe.

  • yes the actual file name contains the # symbol. I've tried using %23, no difference. May 14 '11 at 1:23
  • Escaping won't help, so the first 2 lines of your answer are correct ;-0 May 19 '11 at 10:31

You need to escape it to %23.

So it should be:



I agree with the previous responses of escaping the '#' symbol to '%23'. When dealing with file names on a website, it is also a good rule of thumb to avoid using special characters and spaces to avoid compatibility issues. Also, from an SEO perspective, consider the following example:


Some search engines will be able to parse a keyword out of this file name, but others will determine that 'thisismykeywordfilename' is all one word. If you change it to the following:


Search engines will then be able to break out the keywords in your file names. If you use spaces in the file name, you may end up with an encoded URL in your address bar that looks like this:


Which is not real nice to look at. When escaping the '#' symbol, you will end up with escaped file names that look similar to the example above. A good strategy if possible would be to simplify your file naming, otherwise, escaped special characters are what you need to do.


You could try encoding the file name as follows.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.