title: IIS 7 Error Codes
body: <p>I'm running a Sitefinity CMS website on IIS 7. I'm seeing a couple of weird results when I'm trying to return a 404 status.</p>
  
  <p>If I go to a URL like:</p>
  
  <p>www.mysitefinitywebsite.com/test.co.uk (I realise this is an invalid address, but someone entered it into the CMS)</p>
  
  <p>As the above is not an ASPX page, I believe IIS handles the error, with the following code:</p>
  
  <pre><code>    &lt;httpErrors errorMode="Custom"&gt;
          &lt;remove statusCode="404" subStatusCode="-1" /&gt;
          &lt;error statusCode="404" prefixLanguageFilePath="" path="/404.aspx" responseMode="ExecuteURL" /&gt;
      &lt;/httpErrors&gt;
  </code></pre>
  
  <p>The url in the address bar remains the same, my custom 404 page (/404.aspx) page is displayed, however a http status code 200 is returned.</p>
  
  <p>If however the following url is typed in:</p>
  
  <p>www.mysitefinitywebsite.com/test.aspx - the ASPX error handler kicks in with the following config:</p>
  
  <pre><code>&lt;customErrors mode="On" &gt;
      &lt;error redirect="~/Sitefinity/nopermissions.aspx" statusCode="403" /&gt;
      &lt;error redirect="~/404.aspx" statusCode="404" /&gt;
  &lt;/customErrors&gt;
  </code></pre>
  
  <p>Again, my custom 404 page is displayed, however the url in the address bar changes to:</p>
  
  <p>www.mysitefinitywebsite.com/404.aspx?aspxerrorpath=/test.aspx</p>
  
  <p>And strangely if I check Firebug, a 302 code is returned for text.aspx and then a status of 200 for /404.aspx?aspxerrorpath=/test.aspx.</p>
  
  <p>I don't completely understand whats going on here, it seems like IIS isnt responding with the status code at all - is this by design? Seems completely crazy!</p>
  
  <p>If it is by design, presumably the only way to resolve it is to programatically return the correct response code?</p>
  
  <p>Thanks in advance
  higgsy</p>