title: Custom error handling for a specific page in ASP.Net
body: <p>On a site I run, I have 404's and 500 errors mapped to redirect to a custom error page for end users; using the following code in my web.config:</p>
  
  <pre><code> ...
   ...
  
   &lt;system.web&gt;
    &lt;customErrors defaultRedirect="/404/default.aspx" mode="RemoteOnly"&gt;
  
       &lt;error statusCode="404" redirect="/404/default.aspx" /&gt;
  
    &lt;/customErrors&gt;
  
    ...
    ...
  </code></pre>
  
  <p>However, I have one specific page that I do not want redirected; a health check page to make sure the site is 100% operational. I tried setting a location specific custom error handler using the code below in my web.config:</p>
  
  <pre><code> ...
   ...
  
     &lt;/system.web&gt;
    &lt;location path="health.aspx"&gt;
      &lt;system.web&gt;
        &lt;customErrors defaultRedirect="" mode="RemoteOnly"&gt;&lt;/customErrors&gt;
      &lt;/system.web&gt;
    &lt;/location&gt;
   ...
   ...
  </code></pre>
  
  <p>However, it doesn't seem to work. When I rename health.aspx to something else like badhealth.aspx, then make a request, I expect to get a generic 404 error via the Yellow Screen of Death page. Similarly, by intentionally changing the code to throw an error, I should get 500 error via the YSOD page. In both cases, I end up being redirected to our custom 404 page, rathen then getting a YSOD. Thoughts?</p>
  
  <p>Any assistance is greatly appreciated.</p>
  
  <p>Thanks all,
  - Frank</p>