How to: Enable Debugging for ASP.NET Applications
To enable debugging, you must enable it in both the Project Properties page and in the application's web.config file.
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Customizing Development Settings.
To enable ASP.NET debugging in the project properties (Visual Basic/C#)
In Solution Explorer, right-click the name of a Web project and select Properties.
In the project properties page click the Web tab.
Under Debuggers, select the ASP.NET check box.
To enable debugging in the web.config file
Open the web.config file by using any standard text editor or XML parser.
You cannot access the file remotely by using a Web browser, however. For security reasons, ASP.NET configures Microsoft IIS to help prevent direct browser access to Web.config files. If you try to access a configuration file by using a browser, you will get HTTP access error 403 (forbidden).
Web.config is an XML file, and so contains nested sections marked by tags. Locate the configuration/system.web/compilation element. If the compilation element does not exist, create it.
If the compilation element does not contain a debug attribute, add the attribute to the element.
Make sure the debug attribute value is set to true.
The web.config file should look like the following example. Note that there can be sections between the configuration and system.web elements
element sections between the configuration and system.web elements
element sections between the system.web and compilation elements
The compilation element can contain other attributes and elements
ASP.NET automatically detects any changes to Web.config files and applies the new configuration settings. You do not have to restart the computer or restart the IIS server for changes to take effect.
A Web site can contain multiple virtual directories and subdirectories, and Web.config files may exist in each one. ASP.NET applications inherit settings from Web.config files at higher levels in the URL path. Hierarchical configuration files allow you to change settings for several ASP.NET applications at the same time, such as for all applications below it in the hierarchy. However, if debug is set in a file lower in the hierarchy, it will override the higher value.
For example, you could specify debug="true" in www.microsoft.com/aaa/Web.config, and any application in the aaa folder or in any subfolder of aaa will inherit that setting. So if your ASP.NET application is at www.microsoft.com/aaa/bbb, it will inherit that setting, as will any ASP.NET applications in www.microsoft.com/aaa/ccc, www.microsoft.com/aaa/ddd, and so on. The only exception is if one of those applications overrides the setting by means of its own lower Web.config file.
Enabling debug mode will greatly affect the performance of your ASP.NET application. Remember to disable debug mode before you deploy a release application or conduct performance measurements.