WebSuccessAuditEvent 类

定义

提供有关成功安全事件的信息。

public ref class WebSuccessAuditEvent : System::Web::Management::WebAuditEvent
public class WebSuccessAuditEvent : System.Web.Management.WebAuditEvent
type WebSuccessAuditEvent = class
    inherit WebAuditEvent
Public Class WebSuccessAuditEvent
Inherits WebAuditEvent
继承
派生

示例

下面的代码示例演示如何从 WebSuccessAuditEvent 类派生以创建自定义审核事件。


using System;
using System.Text;
using System.Web;
using System.Web.Management;

namespace SamplesAspNet
{
    // Implements a custom WebSuccessAuditEvent class. 
    public class SampleWebSuccessAuditEvent :
        System.Web.Management.WebSuccessAuditEvent
    {
        private string customCreatedMsg, customRaisedMsg;

        // Invoked in case of events identified only by their event code.
        public SampleWebSuccessAuditEvent(string msg, 
            object eventSource, int eventCode)
            :
        base(msg, eventSource, eventCode)
        {
            // Perform custom initialization.
            customCreatedMsg =
                string.Format("Event created at: {0}",
                DateTime.Now.TimeOfDay.ToString());
        }

        // Invoked in case of events identified by their event code.and 
        // event detailed code.
        public SampleWebSuccessAuditEvent(string msg, object eventSource,
            int eventCode, int detailedCode)
            :
        base(msg, eventSource, eventCode, detailedCode)
        {
            // Perform custom initialization.
            customCreatedMsg =
            string.Format("Event created at: {0}",
                DateTime.Now.TimeOfDay.ToString());
        }


        // Raises the SampleWebSuccessAuditEvent.
        public override void Raise()
        {
            // Perform custom processing.
            customRaisedMsg =
                string.Format("Event raised at: {0}", 
                DateTime.Now.TimeOfDay.ToString());

            // Raise the event.
            WebBaseEvent.Raise(this);
        }

        // Obtains the current thread information.
        public WebRequestInformation GetRequestInformation()
        {
            // No customization allowed.
            return RequestInformation;
        }

        //Formats Web request event information.
        //This method is invoked indirectly by the provider using one of the
        //overloaded ToString methods.
        public override void FormatCustomEventDetails(WebEventFormatter formatter)
        {
            base.FormatCustomEventDetails(formatter);

            // Add custom data.
            formatter.AppendLine("");

            formatter.IndentationLevel += 1;
            formatter.AppendLine(
                "******** SampleWebSuccessAuditEvent Start ********");
            formatter.AppendLine(string.Format("Request path: {0}",
                RequestInformation.RequestPath));
            formatter.AppendLine(string.Format("Request Url: {0}",
                RequestInformation.RequestUrl));

            // Display custom event timing.
            formatter.AppendLine(customCreatedMsg);
            formatter.AppendLine(customRaisedMsg);

            formatter.AppendLine(
                "******** SampleWebSuccessAuditEvent End ********");

            formatter.IndentationLevel -= 1;
        }
    }
}
Imports System.Text
Imports System.Web
Imports System.Web.Management


' Implements a custom WebSuccessAuditEvent class. 

Public Class SampleWebSuccessAuditEvent
    Inherits System.Web.Management.WebSuccessAuditEvent
    Private customCreatedMsg, customRaisedMsg As String
    
    
    
    ' Invoked in case of events identified only by their event code.
    Public Sub New(ByVal msg As String, _
    ByVal eventSource As Object, ByVal eventCode As Integer)
        MyBase.New(msg, eventSource, eventCode)
        ' Perform custom initialization.
        customCreatedMsg = String.Format("Event created at: {0}", _
        DateTime.Now.TimeOfDay.ToString())

    End Sub
    
    
    ' Invoked in case of events identified by their event code.and 
    ' event detailed code.
    Public Sub New(ByVal msg As String, ByVal eventSource As Object, _
    ByVal eventCode As Integer, ByVal detailedCode As Integer)
        MyBase.New(msg, EventSource, eventCode, detailedCode)
        ' Perform custom initialization.
        customCreatedMsg = String.Format("Event created at: {0}", _
        DateTime.Now.TimeOfDay.ToString())

    End Sub
    
    
    
    ' Raises the SampleWebSuccessAuditEvent.
    Public Overrides Sub Raise() 
        ' Perform custom processing.
        customRaisedMsg = String.Format("Event raised at: {0}", _
        DateTime.Now.TimeOfDay.ToString())
        
        ' Raise the event.
        WebBaseEvent.Raise(Me)
    
    End Sub
    
    
    ' Obtains the current thread information.
    Public Function GetRequestInformation() As WebRequestInformation 
        ' No customization allowed.
        Return RequestInformation
    
    End Function 'GetRequestInformation
    
    
    'Formats Web request event information.
    'This method is invoked indirectly by the provider using one of the
    'overloaded ToString methods.
    Public Overrides Sub FormatCustomEventDetails(ByVal formatter _
    As WebEventFormatter)
        MyBase.FormatCustomEventDetails(formatter)

        ' Add custom data.
        formatter.AppendLine("")

        formatter.IndentationLevel += 1
        formatter.AppendLine("**SampleWebSuccessAuditEvent Start **")
        formatter.AppendLine(String.Format("Request path: {0}", _
        RequestInformation.RequestPath))
        formatter.AppendLine(String.Format("Request Url: {0}", _
        RequestInformation.RequestUrl))

        ' Display custom event timing.
        formatter.AppendLine(customCreatedMsg)
        formatter.AppendLine(customRaisedMsg)

        formatter.AppendLine("** SampleWebSuccessAuditEvent End **")

        formatter.IndentationLevel -= 1

    End Sub
End Class

以下示例是配置文件的摘录,它使 ASP.NET 运行状况监视能够使用 事件。

<healthMonitoring   
..enabled="true"  
..heartBeatInterval="0">   
  <providers>  
    <add name="EventLogProvider"   
    type="System.Web.Management.EventLogWebEventProvider,  
    System.Web,Version=2.0.3600.0,Culture=neutral,  
    PublicKeyToken=b03f5f7f11d50a3a"/>  
  </providers>  
  <eventMappings>  
    <add  name="SampleWebSuccessAuditEvent"   
      type="SamplesAspNet.SampleWebSuccessAuditEvent,  
      websuccessauditevent,Version=1.0.1663.31140,   
      Culture=neutral,   
      PublicKeyToken=0d1fa0f69d94de96,   
      processorArchitecture=MSIL"/>  
  </eventMappings>  
  <rules>  
    <add name="Custom Failure Audit Default"  
      eventName=" SampleWebFailureAuditEvent "  
      provider="EventLogProvider"  
      profile="Default"/>    
  </rules>  
</healthMonitoring>  

注解

ASP.NET 运行状况监视允许生产和运营人员管理已部署的 Web 应用程序。 命名空间 System.Web.Management 包含负责打包应用程序运行状况状态数据的运行状况事件类型和负责处理此数据的提供程序类型。 它还包含有助于管理运行状况事件的支持类型。

WebSuccessAuditEvent成功执行与安全相关的操作时,将使用 类。 一个示例是 Web 请求的成功 URL 授权。

以下列表描述了 ASP.NET 引发 类型 WebSuccessAuditEvent 事件的功能:

WebSuccessAuditEvent引发 时,ASP.NET 运行状况监视会递增相关的审核成功事件引发的性能计数器,healthMonitoring然后检查配置以确定是否有任何提供程序订阅该事件。 如果提供程序订阅事件,ASP.NET 会将事件调度给它们进行处理。

注意

若要查看系统监视器 (PerfMon) 审核成功事件引发的性能计数器,请在“添加计数器”窗口中从“性能对象”下拉列表中选择“ASP.NET”,选择“审核成功事件引发的性能计数器”,然后单击“添加”按钮。 有关详细信息,请参阅 监视 ASP.NET 应用程序性能

由于成功审核表示预期条件,因此你可能不希望订阅它们。 可以订阅它们,以便为站点提供访问审核。

注意

在大多数情况下,你将能够使用 ASP.NET 实现的运行状况监视类型,并通过在配置节中 healthMonitoring 指定值来控制运行状况监视系统。 还可以从运行状况监视类型派生,以创建自己的自定义事件和提供程序。 有关从 WebSuccessAuditEvent 类派生的示例,请参阅本主题中提供的示例。

构造函数

WebSuccessAuditEvent(String, Object, Int32)

使用所提供的参数初始化 WebSuccessAuditEvent 类的新实例。

WebSuccessAuditEvent(String, Object, Int32, Int32)

使用所提供的参数初始化 WebSuccessAuditEvent 类的新实例。

属性

EventCode

获取与该事件关联的代码值。

(继承自 WebBaseEvent)
EventDetailCode

获取事件详细信息代码。

(继承自 WebBaseEvent)
EventID

获取与事件关联的标识符。

(继承自 WebBaseEvent)
EventOccurrence

获取表示事件发生次数的计数器。

(继承自 WebBaseEvent)
EventSequence

获取应用程序已引发事件的次数。

(继承自 WebBaseEvent)
EventSource

获取引发事件的对象。

(继承自 WebBaseEvent)
EventTime

获取引发事件的时间。

(继承自 WebBaseEvent)
EventTimeUtc

获取引发事件的时间。

(继承自 WebBaseEvent)
Message

获取描述事件的消息。

(继承自 WebBaseEvent)
ProcessInformation

获取有关 ASP.NET 应用程序承载进程的信息。

(继承自 WebManagementEvent)
RequestInformation

获取与该 Web 请求关联的信息。

(继承自 WebAuditEvent)

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
FormatCustomEventDetails(WebEventFormatter)

提供事件信息的标准格式设置。

(继承自 WebBaseEvent)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
IncrementPerfCounters()

递增“引发的审核成功事件”性能计数器。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
Raise()

通过将事件已发生这一情况通知任何已配置的提供程序来引发事件。

(继承自 WebBaseEvent)
ToString()

为显示而对事件信息进行格式化。

(继承自 WebBaseEvent)
ToString(Boolean, Boolean)

为显示而对事件信息进行格式化。

(继承自 WebBaseEvent)

适用于

另请参阅