ASP.NET Trace

ASP.NET introduces new functionality that allows you to view diagnostic information about a single request for an ASP.NET page simply by enabling it for your page or application. Called tracing, this feature also allows you to write debug statements directly in your code without having to remove them from your application when it is deployed to production servers. You can write variables or structures in a page, assert whether a condition is met, or simply trace through the execution path of your page or application.

In order for these messages and other tracing information to be gathered and displayed, you must enable tracing for the page or application. When you enable tracing, two things occur:

  • ASP.NET appends a series of diagnostic information tables immediately following the page's output. The information is also sent to a trace viewer application (if you have enabled tracing for the application).
  • ASP.NET displays your custom diagnostic messages in the Trace Information table of the appended performance data.

Diagnostic information and tracing messages that you specify are appended to the output of the page that is sent to the requesting browser. Optionally, you can view this information from a separate trace viewer (Trace.axd) that displays trace information for every page in a given application. This information can help you to clarify errors or undesired results as ASP.NET processes a page request.

Trace statements are processed and displayed only when tracing is enabled. You can control whether tracing is displayed to a page, to the trace viewer, or both.

In This Section