Tracing in .Net 2.0

Tracing is a new feature given in .Net 2.0 that helps the user to view different steps occurred while execution of a single Page at run time. Tracing Information help you to investigate errors or unwanted results while ASP.Net process a page request.

By default tracing is disabled so if you want to view the tracing information you have to enable the tracing.

Tracing can be of two types Page Level Tracing and Application Level Tracing.

Page Level Tracing:

Gives information about a particular page.

To enable the page level tracing Add "Trace=true" in Page directive of ASP.Net Page

<%@ Page Trace="true" %>

Other attribute that you can use here is TraceMode

Set TraceMode to SortByTime to soert the Information in order in which they were processed.

Set TraceMode to SortByCategory to sort the Information in the different categories

<%@ Page Language="VB" Trace="True" TraceMode="SortByCategory" %>

Application Level Tracing:
Gives information about whole application.

Application level tracing can be enabled in web.config file by using the trace element inside system.web tag.

<trace enabled="true" />

Other elements that can be used are

pageOutput-> Set this element to true if you want to display trace information at the end of page ;Set this element to false if you want to display trace information in TraceViewer.

requestLimit-> Number that indicates for how many requests trace information is required.

Note: Trace attribute in Page directive overwrites the trace attribute in web.config file.

How to view trace information with trace viewer
To do this tracing should be enabled in web.config file.
  1. Navigate to trace.axd in the root of your application.

    For example, if the URL for your application is http://localhost/SampleApplication, navigate to http://localhost/SampleApplication/trace.axd to view the trace information for that application.
  2. Select the View Details link for the request that you want to investigate.