ASP.NET Applications > ASP.NET Optimization > ASP.NET Trace Functionality > Page-level Tracing > Displaying Trace Messages on the Page
ASP.NET Web Applications ASP.NET Trace Functionality
Once you have written trace statements for your page or control, you can display them in your browser. To do this, you must enable tracing for the page in which you want the messages to be displayed. Tracing is disabled by default.
To enable tracing, you use the Trace attribute of the @ Page directive .
<%@ Page Trace = "true" %>
When you set the Trace attribute to true, the TraceContext.IsEnabled property is set to true as well.
NOTE: If you enable tracing at the application level, it is automatically enabled for each page in the application. However, to view trace information on a page you must use the PageOutput attribute in your application’s Web.config
file. For more information, see Enabling Application-level Tracing.
You can also use the TraceMode attribute of the @ Page directive to specify how you want your trace messages to be sorted when they are displayed on the page. You can set this attribute to either SortByTime, which is the default, or SortByCategory. SortByTime displays trace messages in the order that they were processed on the page. SortByCategory displays messages alphabetically by the category that you assigned them when you wrote the code. For example, the following code would sort a pages trace messages by category.
<%@ Page Language = "VB" Trace = "True" TraceMode = "SortByCategory" %>
NOTE: When tracing is enabled for a page, trace information will be displayed on any browser that requests the page from the server. Be sure to disable page display for tracing before porting your application to a production server.
Application-level Tracing Page-level Tracing @ Page Writing to the Trace Log