3

I've to show with a browser some files that contains this # on the name. Using it on the url the file seems to be not available.

How can I configure IIS or my web.config to allow this?

thanks, Andrea

Andrea Girardi
  • 4,337
  • 13
  • 69
  • 98

3 Answers3

9

That's not how URLs work.

The # character is used to denote the hash portion; anything after it is not sent to the server.

You need to escape the # as %23

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
3

Use the URLEncode method to encode the filename for the querystring

As mentioned, the # character is a special character to denote a bookmark on a page

cusimar9
  • 5,185
  • 4
  • 24
  • 30
2

You need to UrlEncode the file name as you build your URL. This will escape the '#' character, allowing the browser to interpret it appropriately.

Proper encoding is very important for preventing Cross-Site Scripting attacks against your application, which can be devastating.

John Bledsoe
  • 17,142
  • 5
  • 42
  • 59