Chapter 19. Tracing, Debugging, and Error Handling

Every computer programmer has run into bugs. It comes with the territory. Many bugs are found during the coding process. Others pop up only when an end-user performs a specific and unusual sequence of steps or the program receives unexpected data. It is highly desirable to find bugs early in the development process, and it is very important to avoid having end-users find your bugs for you. Countless studies have shown that the earlier you find a bug, the easier and less expensive it is to fix.

In the event that your program does run into a problem, you will want to recover quickly and invisibly, or, at worst, fail gracefully. ASP.NET provides tools and features to help you reach these goals:

Tracing

You can trace program execution at either the page or the application level. ASP.NET provides an extensible trace log with program life cycle information.

Symbolic debugging

You can step through your program, set breakpoints, examine and modify variables and expressions, and step into and out of classes, even those written in other languages.

Error handling

You can handle standard or custom errors at the application or page level. You can also show different error pages for different errors.

To get started exploring the ASP.NET debugging tools, you’ll create a simple website to which you will add tracing code. You will then introduce bugs into the program and use the debugger to find and fix the bugs.

Get Programming ASP.NET 3.5, 4th 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.