How to show error information with ASP.NET on IIS7

Posted: 05/24/2012

There are two things that we can set on the ASP.NET side in the web.config that can help with this problem. First, the tradional “customErrors” section of the web.config that goes in the section of the web.config:

    <customErrors mode="Off" defaultRedirect="GenericErrorPage.htm">
      <error statusCode="403" redirect="NoAccess.htm"/>
      <error statusCode="404" redirect="FileNotFound.htm"/>
    </customErrors>

Next, in the <system.webserver> section of the web.config there are two tags you should add:

I should note, for these I’m currently using the .Net Framework 4.0 on IIS7. There is one more thing you can try if the above doesn’t work. Here are the steps (I believe that setting this in IIS will open up detailed messages for everyone connecting to your site so this may not be desirable depending on your situation):

  1. Open the IIS7 Manager
  2. Select the web-site you want, then double click on “Error Pages”
  3. Right click and select “Edit Feature Settings”
  4. Select the “Detailed errors” radio button and click “OK”.