How do you enable tracing in on an ASP.NET page?

 Posted by ArticlesMaint on 9/16/2009 | Category: ASP.NET Interview questions | Views: 2971

Answer: -
To enable tracing on an ASP.NET page we need to put the ‘trace’ attribute to true on the page attribute as shown in figure ‘Tracing in Action’ ( Its numbered as 1 in the figure). In the behind code we can use the trace object to put tracing like one we have shown on the page load numbered as (4). We have used the ‘trace.write’ to display our tracing. You can also see the trace data which is circled. 2 and 3 show the actual data. You can see how trace shows in details the tracing information for a page with events and time period for execution. If you make the ‘trace’ as false you will only see the actual display i.e. ‘This is the actual data’. So you can enable and disable trace with out actually compiling and uploading new DLL’s on production environment.

The above sample enables tracing only at page level. To enable tracing on application level we need to modify the ‘web.config’ file and put the ‘trace’ tag with ‘enabled=true’.

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

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response