[Previous] [TOC]

Conclusion

Web development is difficult because an application's state can be all over the place. For example, the application holds some of the state, the browser holds some of the state, and some of the state is stuck in a session database. In addition, the executing portions of an application happen in multiple places-both on the server and on the client. That calls for debugging techniques different from what you'd require with a desktop application.

ASP.NET supports per-page tracing and application-level tracing. In both cases, ASP.NET displays the entire context of a request and response, including tracing statements. Visual Studio also supports debugging ASP.NET applications as though they were desktop applications. You simply set up breakpoints, fire up the debugger, and watch the fireworks. Debugging ASP.NET applications is very much like debugging desktop applications, thanks to Visual Studio.

Finally, ASP.NET takes over the custom error page handling process (which used to be managed by IIS in classic ASP). You may direct users to new pages depending upon the error that occurs. Finally, you can trap exceptions before they redirect and perform additional processing.

Tutorial 16 Quick Reference

How to prepare a Web site for debugging

Include the following in Web.Config:

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


How to enable tracing for an entire application

Include the following in Web.Config:

<system.web>
    <trace enabled="true"/>
</system.web>


How to enable tracing for your page

Set the Page class's trace attribute to true using either the property page in Visual Studio or by declaring trace=true in the page directive


How to debug a Web application in Visual Studio

  1. Ensure that the debug attribute is turned on in Web.Config

  2. Start the program running in debug mode by

  3. Selecting Debug | Start Debugging from the main menu

    OR

  4. 2. Hitting the F5 key


How to set up breakpoints in an application in Visual Studio

  1. Place the cursor on the line at which you'd like to stop execution and

  2. Select Debug | Toggle Breakpoint

    OR

  3. Hit the F9 key


How to execute a line of source code in the Visual Studio debugger

  1. While the debugger is running and execution has stopped at the line you'd like to execute

  2. 1. Select Debug | Stop Over from the main menu

    OR

  3. 2. Hit the F10 key


How to step INTO a line of source code in the Visual Studio debugger

While the debugger is running and execution has stopped at the line you'd like to execute


How to instruct ASP.NET to show a specific page when an error occurs

Assign the error handling page to the specfic error in the <customErrors> section of Web.Config


How to trap specific errors in ASP.NET

Handle uncaught exceptions within the Application_Error handler in Global.ASAX. Usually, redirect to a specific page


[Previous] [TOC]