大网数据广告活动
Web服务器与PHP

Disable Debugging for ASP.NET Application

· 52CE 我爱测

This article discusses how to disable debugging for ASP.NET applications.

This article explains how to disable debugging for ASP.NET applications running on .NET Framework.

Original product version:   ASP.NET
Original KB number:   815157

Summary

ASP.NET supports compiling applications in a special debug mode that helps developers troubleshoot. Debug mode causes ASP.NET to compile applications with extra information. The extra information enables a debugger to closely monitor and control the execution of an application. Applications that are compiled in debug mode execute as expected. However, the performance of the application is affected. To avoid the effect on performance, enable debugging only when a developer is doing interactive troubleshooting.

Debugging is disabled by default. Developers frequently enable debugging to troubleshoot a problem but don't disable it after the problem is resolved. This article describes how to disable debugging for an ASP.NET application.

To disable debugging, modify the Web.config file or the Machine.config file, as detailed in the following sections.

Modify the Web.config file

To disable debugging, add the compilation element to the Web.config file of the application by following these steps. The Web.config file is located in the application directory.

  1. Open the Web.config file in a text editor, such as Notepad. The file is typically located in the application directory.

  2. In the Web.config file, locate the compilation element. Debugging is enabled when the debug attribute in the compilation element is set to true.

  3. Change the debug attribute to false to disable debugging for that application.

    The following code sample shows the compilation element with debug set to false:

    <compilation debug="false"/>
    
  4. Save the Web.config file. The ASP.NET application automatically restarts.

Use IIS Manager (if the web application is hosted on IIS)

  1. Open IIS Manager on the computer where the website is hosted. You can select <kbd>Windows</kbd> + <kbd>R</kbd> and type inetmgr:

    :::image type="content" source="media/disable-debugging-application/type-inetmgr-run-window.png" alt-text="Screenshot of typing inetmgr in the Run window.":::

  2. Select the website or web application for which you want to enable or disable debug mode from the left-hand side tree view:

    :::image type="content" source="media/disable-debugging-application/enable-disable-debug-mode-web-application.png" alt-text="Screenshot of website or web application for which you want to enable or disable debug mode." lightbox="media/disable-debugging-application/enable-disable-debug-mode-web-application.png":::

  3. From the middle pane of IIS Manager, select the .NET Compilation icon:

    :::image type="content" source="media/disable-debugging-application/net-compilation-icon.png" alt-text="Screenshot of the .NET Compilation icon." lightbox="media/disable-debugging-application/net-compilation-icon.png":::

  4. In the list of parameter values displayed in the middle pane of IIS Manager, set the value of Debug under the Behavior category to:

    • True: Enable debug mode.
    • False: Disable debug mode.

    :::image type="content" source="media/disable-debugging-application/set-value-debug-under-behavior-category.png" alt-text="Screenshot of setting the value of Debug under the Behavior category." lightbox="media/disable-debugging-application/set-value-debug-under-behavior-category.png":::

  5. Select the Apply button from the right-hand side pane of IIS Manager to save the changes to the IIS configuration:

    :::image type="content" source="media/disable-debugging-application/apply-button-iis-manager.png" alt-text="Screenshot of the Apply button in IIS Manager." lightbox="media/disable-debugging-application/apply-button-iis-manager.png":::

Modify the Machine.config file

Caution: Be careful when editing Machine.config. This file applies globally to all .NET applications on the server, and a misconfiguration can break other applications. To target only specific sites, prefer setting debug="false" in the application’s Web.config or via IIS Manager.

You can also disable debugging for all applications on a system by modifying the Machine.config file. To confirm that debugging isn't enabled in the Machine.config file, follow these steps:

  1. Open the Machine.config file in a text editor, such as Notepad. The file is typically located in the following folder:

    %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\

    For 64-bit versions of the .NET Framework, the file is in the following folder:

    %SystemRoot%\Microsoft.NET\Framework64\%VersionNumber%\CONFIG\

  2. In the Machine.config file, locate the compilation element. Debugging is enabled when the debug attribute in the compilation element is set to true.

  3. If the debug attribute is true, change the debug attribute to false.

    The following code sample shows the compilation element with debug set to false:

    <compilation debug="false"/>
    
  4. Save the Machine.config file.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 02/10/2026
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。