To |
Do this |
---|---|
Enable page-level tracing |
Add the Trace attribute to the @ Page directive and set its value to true. |
Enable application-level tracing |
Add the <trace> configuration section to Web.config with the desired attributes. At a minimum, the enabled attribute is required and should be set to true. |
Write to the trace output |
Call either the Trace.Write or Trace.Warn method, passing the appropriate arguments. |
View detailed error information or prepare for using the runtime debugger |
Compile your page or pages in Debug mode by either adding the Debug attribute to the @ Page directive with a value of true or adding the <compilation> section to the Web.config file and setting its debug attribute to true. |
Invoke the runtime debugger |
Locate the file DbgCLR.exe and execute it. |
Debug a page using the Visual Studio .NET debugger |
Ensure that the page is set to compile in debug mode, which is the default in Visual Studio .NET. Set breakpoints by clicking on the gray bar on the left side of the code window. |
Make a breakpoint conditional |
Set a breakpoint as earlier in the chapter, and then right-click on the line and select Breakpoint Properties from the context menu. Set a condition (to break only when a condition is met) or a hit count (to break only after some number of passes through the line where the breakpoint is). |
To disable debugging when moving an application to production |
In Web.Config, in the <compilation> tag, set debug to false. In the Build menu, select Configuration, change the configuration for the project involved to Release, and then rebuild the application. |