|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
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 andirective 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" %>
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 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 directive is set to true.. The Trace attribute in the directive takes precedence over attributes set in the
Optionally, include the TraceMode attribute to specify the order in which you want your trace messages to appear:
Set TraceMode toto sort trace messages in the order in which they are processed.
Set TraceMode toto sort trace messages by the categories that you specified in the and 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" %>