How to: Enable Tracing for an ASP.NET Page
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" %>
Security Note 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 (ASP.NET Settings Schema). The Trace attribute in the @ Page directive takes precedence over attributes set in the trace element in the Web.config file. Therefore, even if you disable tracing in the Web.config file by setting the enabled attribute to false, the page might still show tracing information if the Trace attribute in its @ Page directive is set to 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 System.Web.TraceContext.Warn and System.Web.TraceContext.Write method 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" %>
See Also
Tasks
How to: Enable Tracing for an ASP.NET Application
Reference
Concepts
Writing Custom ASP.NET Trace Messages
Reading ASP.NET Trace Information