Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Tracing for an ASP.net application

0.00/5 (No votes)
15 Apr 2010 1  
ASP.net offers a built-in functionality for tracing theapplication. Using this functionality one can view a lot ofdiagnostic

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

ASP.net offers a built-in functionality for tracing the application. Using this functionality one can view a lot of diagnostic information which is rendered as the page output when the tracing is enabled. This tracing information can also be viewed using Trace Viewer. Tracing is output in a tabular format on the page and in the trace viewer too.

As many other features, tracing can be enabled at the page level as well as at the application level.

To enable tracing at the Page level, include Trace=”true” attribute in the @Page directive, for the page you want tracing to be enabled.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestTracing._Default"

Trace="true"%>

Run your application, and you'll see the Tracing information on the page where tracing has been made enabled. This information is always showed at the bottom of the page after all the page controls are done with rendering. So, if you have nothing on the page, the page will be showing only the Tracing information.

To enable tracing at the Application level, add a trace element as a child to the system.web element and set its 'enabled' attribute to 'true'.

<system.web>

<trace enabled="true" pageOutput="true" requestLimit="10"/>

</system.web>

The other attributes include;

pageOutput; which lets you choose whether to output the tracing information in the page too or only in the trace viewer. requestLimit; number of trace requests to store on the server. Default value is 10 for this attribute.

To use Trace Viewer for viewing Tracing information, just navigate to “Trace.axd” in your application. Its in the root and you can navigate to it by entering URL like this “http://localhost/MyApplication/Trace.axd”

Tracing information includes; Request Details, Trace Information, Control Tree, Session Collection, Cookies Collection, Forms Collection, Headers Collection, Server Variables.

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here