Chapter 6. Tracing

ONE OF THE MOST COMMON WAYS to debug traditional ASP web applications is to use trusty calls to Response.Write. This enables you to create checkpoints in your code to view the contents of variables in the browser. This approach had several drawbacks, however. The output created by calls to Response.Write appears wherever the call is made in the code. It sometimes becomes a chore trying to interpret your debugging information because it is strewn all over the page in the browser. The formatting of your page is also affected.

When you are finished debugging your web application using calls to Response.Write, you are then faced with the daunting task of stripping out all this debug code. Because you are using the same type of code both to debug and to create valid output, you must carefully scan each of your ASP pages to make sure that you remove all the Response.Write calls that pertain to debugging. When your ASP pages get to be hundreds of lines long, this can be a real pain.

To address this issue, ASP.NET implements the TraceContext class. The TraceContext class solves all these issues and offers many more features. Let’s take a look at some of the ways that the TraceContext class can help you debug your ASP.NET web applications more effectively.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset