title: Configuring custom ASP 404 page with redirect for IIS7 website
body: <p>We're migrating an existing website from IIS6 to IIS7, but are experiencing some difficulty in setting up the 404 error page. Our 404-errorpage works like this:</p>
  
  <ul>
  <li>A custom ASP-page checks the URL against a short list of 'special' URLs (e.g. <a href="http://example.com/limited-offers" rel="nofollow">http://example.com/limited-offers</a>).</li>
  <li>If the URL is known, it redirects to the actual URL of that page.</li>
  <li>Otherwise the visitor is redirected to a static errorpage with a 404-statuscode.</li>
  </ul>
  
  <p>With IIS6 this worked as advertised, but with IIS7 some things have changed. IIS7 will always display the configured errorpage when it encounters a statuscode for which an errorpage is defined. In case of our static errorpage with 404-statuscode, this means that IIS7 will execute the custom ASP-page again. This leads to infinite redirection.</p>
  
  <p>We've discovered that this behavior can be circumvented by adding a setting in Web.Config</p>
  
  <pre><code>&lt;system.webServer&gt;
    &lt;httpErrors existingResponse="PassThrough" /&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>However, after adding this our custom ASP-page refuses to redirect. After checking with Fiddler it seems that IIS7 forces the 404 statuscode, overwriting our 302 redirect.</p>
  
  <p>Can anyone recommend another approach to solve our problem?</p>