Bagikan melalui


WebFailureAuditEvent Kelas

Definisi

Menyediakan informasi tentang kegagalan keamanan.

public ref class WebFailureAuditEvent : System::Web::Management::WebAuditEvent
public class WebFailureAuditEvent : System.Web.Management.WebAuditEvent
type WebFailureAuditEvent = class
    inherit WebAuditEvent
Public Class WebFailureAuditEvent
Inherits WebAuditEvent
Warisan
Turunan

Contoh

Contoh kode berikut menunjukkan cara memperoleh dari WebFailureAuditEvent kelas untuk membuat peristiwa audit kustom.


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

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

        // Invoked in case of events identified only by their event code.
        public SampleWebFailureAuditEvent(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 SampleWebFailureAuditEvent(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 SampleWebFailureAuditEvent.
        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 is 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(
                "******** SampleWebFailureAuditEvent 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(
                "******** SampleWebFailureAuditEvent End ********");

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


' Implements a custom WebFailureAuditEvent class. 

Public Class SampleWebFailureAuditEvent
    Inherits System.Web.Management.WebFailureAuditEvent
    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 SampleWebFailureAuditEvent.
    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 is 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("******** SampleWebFailureAuditEvent 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("******** SampleWebFailureAuditEvent End ********")

        formatter.IndentationLevel -= 1

    End Sub

End Class

Kutipan konfigurasi berikut menunjukkan cara mengaktifkan ASP.NET untuk menggunakan peristiwa.WebFailureAuditEvent

<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="SampleWebFailureAuditEvent"
type="SamplesAspNet.SampleWebFailureAuditEvent,
webfailureauditevent,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>

Keterangan

ASP.NET pemantauan kesehatan memungkinkan staf produksi dan operasi untuk mengelola aplikasi Web yang disebarkan. Namespace System.Web.Management berisi jenis peristiwa kesehatan yang bertanggung jawab untuk mengemas data status kesehatan aplikasi dan jenis penyedia yang bertanggung jawab untuk memproses data ini. Ini juga berisi jenis pendukung yang membantu selama pengelolaan peristiwa kesehatan.

Kelas WebFailureAuditEvent digunakan ketika operasi keamanan gagal. Contohnya adalah otorisasi URL yang gagal untuk permintaan Web.

Secara default, ASP.NET dikonfigurasi untuk meningkatkan WebFailureAuditEvent peristiwa untuk fitur berikut:

WebFailureAuditEvent Saat peristiwa dinaikkan, ASP.NET pemantauan kesehatan meningkatkan penghitung kinerja Peristiwa Kegagalan Audit terkait Dan kemudian memeriksa healthMonitoring bagian konfigurasi untuk menentukan apakah ada penyedia yang berlangganan peristiwa tersebut. Jika penyedia berlangganan acara, ASP.NET mengirimkan peristiwa kepada mereka untuk diproses.

Catatan

Untuk melihat Penghitung kinerja Peristiwa Kegagalan Audit yang dinaikkan di Monitor Sistem (PerfMon), di jendela Tambahkan Penghitung , pilih ASP.NET dari daftar drop-down Objek performa , pilih penghitung kinerja Peristiwa Kegagalan Audit Yang dinaikkan , dan klik tombol Tambahkan .

Catatan

Dalam kebanyakan kasus, Anda akan dapat menggunakan jenis pemantauan kesehatan ASP.NET seperti yang diterapkan, dan Anda akan mengontrol sistem pemantauan kesehatan dengan menentukan nilai di bagian healthMonitoring konfigurasi. Anda juga dapat memperoleh dari jenis pemantauan kesehatan untuk membuat peristiwa dan penyedia kustom Anda sendiri. Untuk contoh turunan dari WebFailureAuditEvent kelas, lihat bagian Contoh.

Catatan Bagi Inheritor

Saat memformat informasi peristiwa kustom Anda untuk ditampilkan, ganti FormatCustomEventDetails(WebEventFormatter) metode daripada ToString metode . Ini akan menghindari penimpaan atau perubahan dengan informasi sistem sensitif.

Konstruktor

WebFailureAuditEvent(String, Object, Int32)

Menginisialisasi instans WebFailureAuditEvent baru kelas menggunakan parameter yang disediakan.

WebFailureAuditEvent(String, Object, Int32, Int32)

Menginisialisasi instans WebFailureAuditEvent baru kelas menggunakan parameter yang disediakan.

Properti

EventCode

Mendapatkan nilai kode yang terkait dengan peristiwa.

(Diperoleh dari WebBaseEvent)
EventDetailCode

Mendapatkan kode detail peristiwa.

(Diperoleh dari WebBaseEvent)
EventID

Mendapatkan pengidentifikasi yang terkait dengan peristiwa.

(Diperoleh dari WebBaseEvent)
EventOccurrence

Mendapatkan penghitung yang menunjukkan berapa kali peristiwa terjadi.

(Diperoleh dari WebBaseEvent)
EventSequence

Mendapatkan berapa kali peristiwa telah dinaikkan oleh aplikasi.

(Diperoleh dari WebBaseEvent)
EventSource

Mendapatkan objek yang meningkatkan peristiwa.

(Diperoleh dari WebBaseEvent)
EventTime

Mendapatkan waktu ketika acara dinaikkan.

(Diperoleh dari WebBaseEvent)
EventTimeUtc

Mendapatkan waktu ketika acara dinaikkan.

(Diperoleh dari WebBaseEvent)
Message

Mendapatkan pesan yang menjelaskan peristiwa.

(Diperoleh dari WebBaseEvent)
ProcessInformation

Mendapatkan informasi tentang proses hosting aplikasi ASP.NET.

(Diperoleh dari WebManagementEvent)
RequestInformation

Dapatkan informasi yang terkait dengan permintaan Web.

(Diperoleh dari WebAuditEvent)

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
FormatCustomEventDetails(WebEventFormatter)

Menyediakan pemformatan standar informasi peristiwa.

(Diperoleh dari WebBaseEvent)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan dari instans Type saat ini.

(Diperoleh dari Object)
IncrementPerfCounters()

Menaikkan Peristiwa Kegagalan Audit Penghitung kinerja yang dinaikkan.

MemberwiseClone()

Membuat salinan dangkal dari saat ini Object.

(Diperoleh dari Object)
Raise()

Memunculkan peristiwa dengan memberi tahu penyedia yang dikonfigurasi bahwa peristiwa telah terjadi.

(Diperoleh dari WebBaseEvent)
ToString()

Memformat informasi peristiwa untuk tujuan tampilan.

(Diperoleh dari WebBaseEvent)
ToString(Boolean, Boolean)

Memformat informasi peristiwa untuk tujuan tampilan.

(Diperoleh dari WebBaseEvent)

Berlaku untuk

Lihat juga