Click here to Skip to main content
11,428,876 members (62,660 online)
Click here to Skip to main content

Tracing for an ASP.net application

, 11 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
ASP.net offers a built-in functionality for tracing theapplication. Using this functionality one can view a lot ofdiagnostic

Editorial Note

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ASP.NET Community

United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.

The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
Group type: Collaborative Group

490 members


Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150428.2 | Last Updated 11 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid