Skip to Content
Beginning ASP.NET 3.5: In C# and VB
book

Beginning ASP.NET 3.5: In C# and VB

by Imar Spaanjaars
March 2008
Intermediate to advanced content levelIntermediate to advanced
766 pages
21h 15m
English
Wrox
Content preview from Beginning ASP.NET 3.5: In C# and VB

A.17. Chapter 17

A.17.1.

A.17.1.1.
A.17.1.1.1. Exercise 1 solution

Debugging is the process of watching your code execute in the development environment, investigating variables and looking into objects in order to understand the execution path of your code, looking for bugs with the aim to fix them. Debugging usually takes place at development time in your Visual Web Developer IDE.

Tracing, on the other hand, provides you with information on the run-time execution of your code. As discussed in this chapter, you can use tracing to get information about events that fire and the order they fire in. Additionally, you can add your own information to the trace. Since disabling tracing through configuration greatly minimizes the performance overhead associated with it, you can leave your trace calls in the code, making it easy to disable and enable tracing whenever you need it.

A.17.1.1.2. Exercise 2 solution

The best way to stop a possible exception from ending up in the user interface is to wrap your code in a Try/Catch block. That way you can display an error message to the user in case something goes wrong. Your code could end up looking like this:

VB.NET

Try
  ' Execute code here to send an e-mail or write to a file.
Catch ex As Exception
  lblErrorMessage.Text = "Something went wrong while executing the requested operation"
End Try

C#

try
{
  // Execute code here to send an e-mail or write to a file.
}
catch (Exception ex)
{ lblErrorMessage.Text = "Something went wrong while executing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning ASP.NET 4: in C# and VB

Beginning ASP.NET 4: in C# and VB

Imar Spaanjaars
Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Bill Evjen, Scott Hanselman, Devin Rader

Publisher Resources

ISBN: 9780470187593Purchase book