Chapter 17. Exception Handling, Debugging, and Tracing

You can't make an omelet without breaking eggs and you cannot write code without creating bugs. No matter how hard you try and how good you are, your code will contain problems that affect the behavior of your web site.

Of course you should strive to minimize the impact of these bugs, aiming for a "zero bug count." To aid you in this, the ASP.NET run time and Visual Web Developer provide you with a number of tools.

First of all, the languages supported by .NET implement exception handling, a methodology to identify and handle errors that occur at run time. By handling these errors, you can present your users a friendly error message. At the same time you can log these errors, giving you a chance to fix them before they reoccur. In this chapter you see how exception handling works, and how to log your errors by e-mail.

Before your code goes into production you need to write and debug it first. To help you debug your code, VWD comes with a rich toolset that includes ways to step through your code line by line, look at your variables and objects at run time, and even change them as you go. The toolset also provides you with valuable information about the execution path your code follows: the path that your application takes through your code, following methods, event handlers, If and Else statements, and so on.

In particular, this chapter looks at the following topics:

  • How to write code that is able to detect and handle errors ...

Get Beginning ASP.NET 3.5: In C# and VB 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.