Detailed error pages can help diagnose a website problem on Windows IIS. This guide covers IIS errors and ASP.NET Framework applications using a web.config file; ASP.NET Core applications use different error-handling settings.
Detailed errors can reveal paths, configuration and application details. Use them on a restricted test site or locally on the server, and restore the previous settings after diagnosis.
Enable detailed errors temporarily
- Back up the website’s existing web.config file.
- Open it in a text editor.
- For an ASP.NET Framework application, change or add the customErrors element inside the existing system.web section:
<customErrors mode="Off" />- Change or add the httpErrors element inside the existing system.webServer section:
<httpErrors errorMode="Detailed" />- Save the file and reproduce the error on the restricted site.
Keep the existing configuration element and other settings. Do not replace the whole file or add duplicate sections. If the section is locked by the server, ask the administrator to make the change at the appropriate level.
Restore the normal error pages
Restore the settings from your backup and test from a remote browser. For local diagnosis without exposing details to remote visitors, ASP.NET Framework supports RemoteOnly, and IIS supports DetailedLocalOnly:
<customErrors mode="RemoteOnly" /><httpErrors errorMode="DetailedLocalOnly" />Merge each element into its respective section. Application error handling or a reverse proxy can affect what visitors see, so verify the actual response.