Tip# 77: Did you know… How to enable Page Level Tracing for your ASP.NET pages?

Enabling tracing at page level gives you a bunch of information that can be useful while debugging your application.Tracing helps understand which control uses more view state,  start/end of PreInit, start/end of Init, start/end of Render, etc. This information appears at the bottom of the page. By default page level tracing is disabled.

Tracing can be enabled at Page Level and also at Application Level

To enable Tracing at Page Level select DOCUMENT in Property grid and set it’s Trace property to true as shown below.

Enable trace for a page.

This will add Trace="true" in your page directive as shown below.

<%@ Page Language="VB"  Trace="true" %>

You can also add TraceMode attribute to specify if you want the trace messages to be SortedByTime or SortByCategory.

You can now run the page and see the details as follows:

Tracing Enabled

You can enable Application level tracing in the Web.config file of your application’s root. By doing this you will get trace information for all pages in your application. In this case you can set page level tracing to false if you do not want tracing information for particular pages.

<configuration> <system.web>

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

</system.web></configuration>

Remember to turn it off before you move your application to production. Also, know that the page level trace setting overrides the trace setting at the application level.

Enjoy Tracing!

Reshmi Mangalore

SDET, Visual Web Developer