Mobile app version of vmapp.org
Login or Join
Connie744

: DOwnload file from IIS7 server with # in file name 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.d

@Connie744

Posted in: #AspNet #Iis7

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.
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?

Thanks

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Connie744

3 Comments

Sorted by latest first Latest Oldest Best

 

@Sent6035632

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:
mydomain.com/ThisIsMyKeywordFileName.pdf
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:
mydomain.com/This-Is-My-Keyword-File-Name.pdf
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:
mydomain.com/This%20Is%20My%20Keyword%20File%20Name.pdf.
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.

10% popularity Vote Up Vote Down


 

@Welton855

You need to escape it to %23.

So it should be:
www.server.com/files/my%23filename.doc

10% popularity Vote Up Vote Down


 

@Correia994

You could try encoding the file name as follows.
www.server.com/files/my%23filename.doc

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme