Debugging

Tracing provides you with a snapshot of the steps your code has taken after the code has run. At times, however, you’d like to monitor your code while it is running. What you want is more of a CAT scan than an autopsy. The code equivalent of a CAT scan is a symbolic debugger.

When you run your code in the debugger, you can watch your code work, step by step. As you walk through the code, you can see the variables change values, and you can watch as objects are created and destroyed.

This section will provide a brief introduction to the most important parts of the debugger that accompanies the VS2005 IDE. For complete coverage of how to use the debugger, we urge you to spend time with the documentation and to experiment freely. The debugger is one of the most powerful tools at your disposal for learning ASP.NET.

An application can be configured to either enable or disable debugging. This is done through the configuration file, web.config, which is described more fully in Chapter 18. The debugging configuration information is contained within the <compilation> section, within the <system.web> section, which in turn is contained within the <configuration> section. So, a typical compilation configuration snippet will look something like Example 7-5.

Example 7-5. Debug configuration code snippet from web.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0" >

   <system.web>
.
.
.
   <compilation
       debug="true"
   />

Setting ...

Get Programming ASP.NET, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.