Page.Trace プロパティ

定義

現在の Web 要求に対する TraceContext オブジェクトを取得します。

public:
 property System::Web::TraceContext ^ Trace { System::Web::TraceContext ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.TraceContext Trace { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Trace : System.Web.TraceContext
Public ReadOnly Property Trace As TraceContext

プロパティ値

現在の Web 要求に対する TraceContext オブジェクトのデータ。

属性

次のコード例では、 プロパティを使用して TraceContext.IsEnabled プロパティと メソッドに TraceContext.Write アクセスする方法を Trace 示します。 このコードは、 オブジェクトに対して Write トレースが有効になっている場合にのみ メソッドを Page 呼び出します。 有効になっていない場合、このコードは実行されず、アプリケーションのオーバーヘッドを軽減するのに役立ちます。

if (Trace.IsEnabled)
{
  for (int i=0; i<ds.Tables["Categories"].Rows.Count; i++)
  {
    Trace.Write("ProductCategory",ds.Tables["Categories"].Rows[i][0].ToString());
  }
}
If (Trace.IsEnabled) Then

  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

注釈

トレースは、Web 要求に関する実行の詳細を追跡して表示します。 レンダリングされたページにトレース データを表示するには、ページ レベルまたはアプリケーション レベルでトレースを有効にする必要があります。

ページ上のトレースは、既定では無効になっています。 ページのトレースを有効にするには、 @ Page ディレクティブ を使用します <% @ Page trace="true" %>。 アプリケーション全体のトレースを有効にするには、アプリケーションのルート ディレクトリにあるアプリケーションの構成ファイル Web.configで有効にする必要があります。 詳細については、「 ASP.NET トレースの概要」を参照してください。

適用対象

こちらもご覧ください