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 健全狀況監視會遞增相關的 Audit Success Events Raised 效能計數器,然後檢查設定 healthMonitoring 以判斷是否有任何提供者訂閱事件。 如果提供者訂閱事件,ASP.NET 將事件分派給他們進行處理。

注意

若要檢視 System Monitor (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)

適用於

另請參閱