Monday, April 19, 2010

Tracing ASP.NET


ASP.NET tracing enable diagnostic information about requested page.
Tracing Help to follow

•    Page's execution path,
•    Display diagnostic information at run time
•    debug your application

Tracing appends diagnostic information and custom tracing messages to the output of the page and sends this information 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 an ASP.NET Web application. Tracing information can help you investigate errors or unwanted results while ASP.NET processes a page request.

Trace information can enable for single page and hole pages/ application level by configure the application's Web.config. Trace statements are processed and displayed only when tracing is enabled.

Code for Application Level tracing
in web.config file   

<trace enabled="true" requestLimit="40" pageOutput="true"             localOnly="false" />

Page level tracing

Add Trace="true" in @page Directives

Eg : <%@ Page Trace="true" %>

Trace Configuration Attributes

PageOutput -  true to display trace both in pages and in the trace viewer (Trace.axd); otherwise, false. The default is false.

requestLimit - The number of trace requests to store on the server. The default is 10.

localOnly - true to make the trace viewer (Trace.axd) available only on the host Web server; otherwise, false. The default is true.

When tracing is enabled for a page, trace information is displayed in any browser requests that page. Tracing displays sensitive information, such as the values of server variables, and can therefore represent a security threat. Be sure to disable page tracing before porting your application to a production server. You can do this by setting the Trace attribute to false or by removing it. You can also configure tracing in the Web.config file by setting the enabled, localOnly, and pageOutput attributes of the trace Element

Source  from MSDN

No comments: