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

Instead of enabling tracing for individual pages, you can enable it for your entire application. In that case, every page in your application displays trace information. Application tracing is useful when you are developing an application because you can easily enable it and disable it without editing individual pages. When your application is complete, you can turn off tracing for all pages at once.

When you enable tracing for an application, ASP.NET collects trace information for each request to the application, up to the maximum number of requests you specify. The default number of requests is 10. You can view trace information with the trace viewer.
By default, when the trace viewer reaches its request limit, the application stops storing trace requests. However, you can configure application-level tracing to always store the most recent tracing data, discarding the oldest data when the maximum number of requests is reached.
To enable tracing for an application
Open your Web site’s Web.config file. If no Web.config file exists, create a new file in the root folder and copy the following into it:

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
</system.web>?
</configuration>

Add a trace element as a child of the system.web element. In the trace element, set the enabled attribute to true.If you want trace information to appear at the end of the page that it is associated with, set the trace element’s pageOutput attribute to true. If you want tracing information to be displayed only in the trace viewer, set the pageOutput attribute to false.
For example, the following application trace configuration collects trace information for up to 40 requests and allows browsers on computers other than the server of origin to display the trace viewer. Trace information is not displayed in individual pages.

<configuration>
<system.web>
<trace enabled="true" pageOutput="false" requestLimit="40" localOnly="false"/>
</system.web>
</configuration>

You can control whether tracing is enabled or disabled for individual pages. If tracing is enabled, when the page is requested, ASP.NET appends to the page a series of tables containing execution details about the page request. Tracing is disabled by default. To enable tracing for a page Include an @ Page directive at the top of your .aspx file.Add a Trace attribute and set its value to true, as shown in the following example:
<%@ Page Trace="true" %>
Optionally, include the TraceMode attribute to specify the order in which you want your trace messages to appear:
Set TraceMode to SortByTime to sort trace messages in the order in which they are processed.
Set TraceMode to SortByCategory to sort trace messages by the categories that you specified in the TraceContext.Warnand TraceContext.Writemethod calls in your page or server control code.
The following example shows how to enable tracing in a page and to sort trace messages by category.
<%@ Page Language="VB" Trace="True" TraceMode="SortByCategory" %>


Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*