Debugging and Tracing in ASP.NET Ajax | 2 | WebReference

Debugging and Tracing in ASP.NET Ajax | 2


[prev]

Debugging and Tracing in ASP.NET Ajax [con't]

How to Enable Tracing

Tracing is a concept that enables you to display the execution path and display diagnostic information at execution time. The Sys.Debug class contains a list of methods that you can use to debug your application, handle trace output, and display the trace messages. The ASP.NET Ajax framework provides two important methods that you can use to display debug and trace information. As an example, you can output a text message in the Debug console windows of the debugger during execution using this code snippet:this._appendConsole(textMessage);. Similarly, to output a text message into a TextArea control in your webform, you can use this._appendTrace(textMessage);. You can also clear the TraceConsole using the clearTrace() method of the Sys.Debug class, like this Sys.Debug.clearTrace();.

Note that if you have a TextArea control in your webform with an ID of TraceConsole, the trace messages are appended to the control. Also, for Sys.Debug to work, the compilation debug attribute in your application's web.config should be set to true:

Summary

Debugging and tracing are inbuilt features in ASP.NET Ajax that enable you to track potential bugs efficiently at development time. Otherwise, these bugs would become a nightmare after the application has been deployed. In this article, I explained debugging and tracing and how you can work with them in your ASP.NET Ajax applications.

Original: February 10, 2010

[prev]