How to Enable Detailed Error Messages in an ASP.NET Website Print

  • enable detailed error messages ASP.NET, ASP.NET show full error stack, customErrors mode off, ASP.NET troubleshooting, debug ASP.NET web.config, show server error details ASP.NET, IIS detailed error remote
  • 0

 

By default, ASP.NET applications show generic error messages when something goes wrong—especially in production environments. While this is good for security, it can make debugging very difficult.

To diagnose issues effectively during development or troubleshooting, you can enable detailed error messages in your ASP.NET application.


Method 1: Update web.config to Show Detailed Errors

You can configure your site to show detailed error information by updating the <customErrors> and <compilation> settings in the web.config file.

Step-by-Step:

  1. Open the web.config file in the root directory of your ASP.NET application.

  2. Locate or add the following sections:

<configuration>
  <system.web>
    <customErrors mode="Off" />
    <compilation debug="true" />
  </system.web>
</configuration>

Explanation:

  • customErrors mode="Off": This disables the custom error pages and shows the full stack trace.

  • debug="true": Enables detailed debugging output (make sure to disable in production).


Method 2: Set detailedErrors in IIS (For Remote Debugging)

If you're debugging remotely and getting only a generic error, you need to enable detailed errors for remote clients.

Instructions:

  1. Open IIS Manager.

  2. Select your website from the left-hand tree.

  3. Double-click Error Pages in the Features View.

  4. Click Edit Feature Settings (in the right panel).

  5. Choose "Detailed errors".

Note: By default, IIS only shows detailed errors on the local machine. You can override this by modifying IIS settings or web.config (see below).


Optional: Use httpErrors for IIS 7 and Above

To allow detailed errors to appear for remote users as well, you can update your web.config:

<system.webServer>
  <httpErrors errorMode="Detailed" />
</system.webServer>

Important Reminders:

  • Never enable detailed errors in production environments, as this may expose sensitive information.

  • Always revert to customErrors mode="On" and debug="false" once troubleshooting is complete.

 


Was this answer helpful?

« Back

Powered by WHMCompleteSolution