TraceContext.IsEnabled Propiedad
Definición
Obtiene o establece un valor que indica si está habilitada la traza para la solicitud web actual.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
Valor de propiedad
true
si está habilitada la traza; en caso contrario, false
.true
if tracing is enabled; otherwise, false
.
Ejemplos
En el ejemplo de código siguiente se muestra cómo se puede determinar si el seguimiento está habilitado para una página.The following code example demonstrates how you can determine whether tracing is enabled for a page. El código recorre en iteración las filas de un conjunto de DataSet, escribiendo instrucciones de seguimiento para cada fila del conjunto de filas.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
Comentarios
Utilice esta marca para comprobar si la página o la aplicación deben generar información de seguimiento antes de escribir nada en el registro de seguimiento.Use this flag to check whether your page or application should output tracing information before it writes anything to the trace log.
El valor de la IsEnabled propiedad depende de los valores de la subsección de la system.web
sección de configuración y el valor del trace
atributo de la Directiva.The value of the IsEnabled property depends on the settings in the subsection of the system.web
configuration section and the value of the trace
attribute of the directive. La opción de seguimiento establecida en la Directiva de página tiene prioridad sobre el conjunto de opciones del archivo de configuración.The tracing option set in the page directive takes precedence over the option set in the configuration file. Establecer el IsEnabled valor mediante programación tiene prioridad sobre el atributo de directiva de página y el valor de configuración.Setting the IsEnabled value programmatically takes precedence over both the page directive attribute and the configuration setting.
Nota
Si establece la IsEnabled propiedad en true
para una aplicación completa, debe establecer explícitamente esta propiedad en false
para cualquier página de la aplicación para la que no desee mostrar información de seguimiento.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.