Tip # 52: Did you know… When deploying your ASP.NET web application, debug=false should be set in web.config

To help troubleshoot problems, developers usually enables the debug mode in web.config file. This causes ASP.NET to produce extra information in the compiled assemblies such as debug symbols, metadata. However, performance will be suffered as it takes longer to compile and run, consumes more memory and resource caching is not performed. Therefore, in production, we should set the debugging option back to false to avoid the effect on performance. There are two ways to achieve this.

1) In web.config file, set <compilation debug=”false”/>

2) You can also disable the <compilation debug=”true”/> switch for all ASP.NET applications on the system in production by setting the following in Machine.config:

        <deployment retail=”true”/>

The setting in machine.config will also turn off trace output in a page and detailed error messages remotely. More information about this switch can be found here.

machine.config file is typically located at %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG.

Anh Phan
SDET, Visual Web Developer

Comments (7)

  1. What's New says:

    To help troubleshoot problems, developers usually enables the debug mode in web.config file. This causes

  2. Kevin Dente says:

    It’s a real pain that this is separate from the build configuration for web app projects. I realize web deployment projects can address this, but that’s not built in to VS. Hopefully VS2010 will improve things here.

  3. My latest in a series of the weekly, or more often, summary of interesting links I come across related to Visual Studio. Ben Scheirman wrote up a walk-through of exporting Visual Studio solutions with SolutionFactory . The Web Developer Tools Team posted

  4. Alex says:

    Thanks for the trick, can you give us the command line to automate this?

    I tried various ways to achieve that with %systemroot%system32inetsrvappcmd.exe without success.

    By the way, I noticed that when compiling the website under the release (vs debug) mode, this flag is automatically set to <compilation debug=”false”/>.

  5. xinqiu says:

    Note, if your Machine.config contains the following content


           <deployment retail=”true”/>


    You cannot debug your web application or website anymore.

  6. DrFunkie says:


      Are you debugging on your production servers?


          <deployment retail=”true”/>


    These settings are for your poduction web servers not your development box.