6

I have a bunch of images that contain ampersands in their names. My site is built on Asp.net MVC3.

When I try to view the image with they urls below my site returns and error.

Example urls:

  1. www.somesite.com/myimages/an-%26-image.jpg
  2. www.somesite.com/myimages/an-&-image.jpg

Error returned: A potentially dangerous Request.Path value was detected from the client (&).

Is there away around this issue? I dont really want to turn off validation or revert to requestValidationMode="2.0" as i've seen suggested as this is only an issues with some images.

All the images are in the same folder (myimages), is it possible to stop validation on a particular folder?

Dave
  • 3,812
  • 5
  • 31
  • 39
  • Maybe it's a silly question, but... Can't you simply bulk rename your images and replace ampersands by underscores? – Jonathan May 07 '11 at 16:13
  • That would work for the majority of cases but some of the ampersands are actually park of brand names and clients dont want the names to be changed in any way. – Dave May 07 '11 at 17:03

1 Answers1

12

I was able to fix this by making the following addition to the Web.config

<httpRuntime requestPathInvalidCharacters="&lt;,&gt;,*,%,:,\,?" />

All that was removed was the &amp;. I learned this by narrowing down which parts of this post were required to fix the problem.

Schmalls
  • 1,434
  • 1
  • 19
  • 19