TraceContext.IsEnabled Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value indicating whether tracing is enabled for the current Web request.
public:
property bool IsEnabled { bool get(); void set(bool value); };
public bool IsEnabled { get; set; }
member this.IsEnabled : bool with get, set
Public Property IsEnabled As Boolean
Property Value
true
if tracing is enabled; otherwise, false
.
Examples
The following code example demonstrates how you can determine whether tracing is enabled for a page. The code iterates through the rows in a dataset, writing trace statements for each row in that dataset.
if (Context.IsEnabled) {
for (int i=0; i<DS.Tables["Categories"].Rows.Count; i++) {
Trace.Write("ProductCategory", DS.Tables["Categories"].Rows[i][0].ToString());
}
}
If (Context.IsEnabled)
Dim I As Integer
For I = 0 To DS.Tables("Categories").Rows.Count - 1
Trace.Write("ProductCategory",DS.Tables("Categories").Rows(I)(0).ToString())
Next
End If
Remarks
Use this flag to check whether your page or application should output tracing information before it writes anything to the trace log.
The value of the IsEnabled property depends on the settings in the trace
subsection of the system.web
configuration section and the value of the trace
attribute of the @ Page
directive. The tracing option set in the page directive takes precedence over the option set in the configuration file. Setting the IsEnabled value programmatically takes precedence over both the page directive attribute and the configuration setting.
Note
If you set the IsEnabled property to true
for an entire application, you must explicitly set this property to false
for any page in the application for which you do not want tracing information displayed.
Applies to
See also
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應