Tracing for an ASP.net application





0/5 (0 vote)
ASP.net offers a built-in functionality for tracing theapplication. Using this functionality one can view a lot ofdiagnostic
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.