title: ASP.NET URL validation
body: <p>We have a custom REST handler on ASP.NET that is configured like this to handle all incoming requests:</p>
  
  <pre><code>&lt;add path="*" verb="*" type="REST.RESTProtocolHandler"/&gt;
  </code></pre>
  
  <p>However, passing it a pipe character, properly encoded or not at all, triggers a validation error that seems to come from inside ASP.NET.</p>
  
  <p>Accessing <code><a href="http://localhost:8080/%7c" rel="nofollow noreferrer">http://localhost:8080/%7c</a></code> or <code><a href="http://localhost:8080/|" rel="nofollow noreferrer">http://localhost:8080/|</a></code> yields this error:</p>
  
  <blockquote>
    <p>[ArgumentException: Illegal characters in path.]
     System.IO.Path.CheckInvalidPathChars(String path) +7489125
       System.IO.Path.Combine(String path1, String path2) +40
       System.Web.Configuration.UserMapPath.GetPhysicalPathForPath(String path, VirtualDirectoryMapping mapping) +114
       System.Web.Configuration.UserMapPath.GetPathConfigFilename(String siteID, VirtualPath path, String&amp; directory, String&amp; baseName) +72
       System.Web.Configuration.UserMapPath.MapPath(String siteID, VirtualPath path) +30
       System.Web.Configuration.UserMapPath.MapPath(String siteID, String path) +31
       System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) +297
       System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath, Boolean permitNull) +51
       System.Web.CachedPathData.GetConfigPathData(String configPath) +341
       System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp) +110
       System.Web.HttpContext.GetFilePathData() +36
       System.Web.HttpContext.GetConfigurationPathData() +26
       System.Web.Configuration.RuntimeConfig.GetConfig(HttpContext context) +43
       System.Web.Configuration.CustomErrorsSection.GetSettings(HttpContext context, Boolean canThrow) +41
       System.Web.HttpResponse.ReportRuntimeError(Exception e, Boolean canThrow, Boolean localExecute) +101
       System.Web.HttpRuntime.FinishRequest(HttpWorkerRequest wr, HttpContext context, Exception e) +383</p>
  </blockquote>
  
  <p>No userland code gets executed. Is this a configuration option somewhere? Reproduced on IIS 7 &amp; VS Studio's 2008 devel server.</p>
  
  <p>Stack Overflow seems to handle this error OK, it looks like a dynamically generated 404 MVC page gets rendered for <a href="https://stackoverflow.com/%7c"><a href="https://stackoverflow.com/%7c">https://stackoverflow.com/%7c</a></a>.</p>
  
  <p>Any ideas?</p>