다음을 통해 공유


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

  1. Include an @ Page directive at the top of your .aspx file.

  2. Add a Trace attribute and set its value to true, as shown in the following example:

    <%@ Page Trace="true" %>
    
    Security noteSecurity 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.

  3. Optionally, include the TraceMode attribute to specify the order in which you want your trace messages to appear:

    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

@ Page
TraceContext

Concepts

Writing Custom ASP.NET Trace Messages
Reading ASP.NET Trace Information

Other Resources

ASP.NET Tracing