This topic has not yet been rated - Rate this topic

TraceContext Class

Captures and presents execution details about a Web request. This class cannot be inherited.

System.Object
  System.Web.TraceContext

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)
public sealed class TraceContext

The TraceContext type exposes the following members.

  Name Description
Public method TraceContext Infrastructure. Initializes a new instance of the TraceContext class.
Top
  Name Description
Public property IsEnabled Gets or sets a value indicating whether tracing is enabled for the current Web request.
Public property TraceMode Gets or sets the sorted order in which trace messages should be output to a requesting browser.
Top
  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method Warn(String) Writes a trace message to the trace log. All warnings appear in the log as red text.
Public method Warn(String, String) Writes trace information to the trace log, including any user-defined categories and trace messages. All warnings appear in the log as red text.
Public method Warn(String, String, Exception) Writes trace information to the trace log, including any user-defined categories, trace messages, and error information. All warnings appear in the log as red text.
Public method Write(String) Writes a trace message to the trace log.
Public method Write(String, String) Writes trace information to the trace log, including a message and any user-defined categories.
Public method Write(String, String, Exception) Writes trace information to the trace log, including any user-defined categories, trace messages, and error information.
Top
  Name Description
Public event TraceFinished Raised by the TraceContext object to expose trace messages after all request information is gathered.
Top

You can use this class to append messages to specific trace categories. For example, if you are creating an instance of the Calendar class for your application, you might include the trace message "Starting To Render" in a rendering procedure, and "Raising OnChange Event" in an event handler procedure.

You can also use the TraceContext class to obtain a set of trace records at the end of request execution for custom processing. For more information, see ASP.NET Tracing Overview.

To enable tracing, set the Trace attribute in the @ Page directive or the IsEnabled property to true. When tracing is enabled, in addition to showing user-provided trace content, the Page class automatically includes performance data, control-tree structure information, and state management content for every request.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ