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,179
  • 12
  • 70
  • 95

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
  • 837,282
  • 173
  • 1,862
  • 1,933
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,053
  • 4
  • 22
  • 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
  • 16,302
  • 4
  • 39
  • 59