title: URL Routing, Image Handler & "A potentially dangerous Request.Path value"
body: <p>I've been experiencing this problem now for quite sometime and have decided to try and get to the bottom of it once and for all by posting the question here for some thought. I have an image handler in a .net 4 website located here: </p>
  
  <p><a href="https://www.amadeupurl.co.uk/ImageHandler.ashx?i=3604" rel="noreferrer">https://www.amadeupurl.co.uk/ImageHandler.ashx?i=3604</a>
  (actual domain removed for privacy)</p>
  
  <p>Now this works fine and serves an image from the web server without problem, I say without problem because if I access the URL it works fine, the image loads, no exception is generated. However someone did visit this exact URL yesterday and an exception was raised along the following lines:</p>
  
  <pre><code>Exception Generated
  Error Message:
  A potentially dangerous Request.Path value was detected from the client (?).
  Stack Trace:
  at System.Web.HttpRequest.ValidateInputIfRequiredByConfig() at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)
  
  Technical Information:
  DATE/TIME: 23/01/2013 03:50:01
  PAGE: www.amadeupurl.co.uk/ImageHandler.ashx?i=3604
  </code></pre>
  
  <p>I understand the error message, thats not a problem I just don't understand why it being generated here, to make things worse I'm unable to replicate it, like I said I click the link the image loads, no exception. I am using URL routing and registered the handler to be ignored in case this was causing an issue with the following code:</p>
  
  <pre><code>routes.Ignore("{resource}.ashx")
  </code></pre>
  
  <p>I'm not sure why else I would be getting the error or what else to try.</p>