This documentation is archived and is not being maintained.

Page.Trace Property

Gets the TraceContext object for the current Web request.

[Visual Basic]
Public ReadOnly Property Trace As TraceContext
public TraceContext Trace {get;}
public: __property TraceContext* get_Trace();
public function get Trace() : TraceContext;

Property Value

Data from the TraceContext object for the current Web request.


Tracing tracks and presents the execution details about a Web request. For trace data to be visible in a rendered page, you must enable tracing at the page or application level.

Tracing on a page is disabled by default. To enable tracing for a page, use the @ Page directive: <%@ Page trace="true" %>. To enable tracing for an entire application, you must enable it in the application's configuration file, web.config, which resides in the root directory ofthe application. For more information, see ASP.NET Trace.


[Visual Basic, C#] The following example demonstrates accessing the TraceContext.IsEnabled property and the TraceContext.Write method accessed through the Page.Trace property. This code calls the Trace.Write method only when tracing is enabled for the Page. If it is not enabled, this code will not run, which can help reduce overhead for your application.

[Visual Basic] 
If (Trace.IsEnabled)

  Dim I As Integer
  For I = 0 To DS.Tables("Categories").Rows.Count - 1

End If

if (Trace.IsEnabled)
  for (int i=0; i<ds.Tables["Categories"].Rows.Count; i++)

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Page Class | Page Members | System.Web.UI Namespace | @ Page | TraceContext | ASP.NET Trace