Udostępnij za pośrednictwem


WebFailureAuditEvent Klasa

Definicja

Zawiera informacje o błędach zabezpieczeń.

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
Dziedziczenie
Pochodne

Przykłady

Poniższy przykład kodu pokazuje, jak pochodzić z klasy w WebFailureAuditEvent celu utworzenia niestandardowego zdarzenia inspekcji.


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

Poniższy fragment konfiguracji przedstawia sposób włączania ASP.NET używania WebFailureAuditEvent zdarzenia.

<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>

Uwagi

ASP.NET monitorowanie kondycji umożliwia pracownikom produkcyjnym i operacyjnym zarządzanie wdrożonych aplikacji internetowych. System.Web.Management Przestrzeń nazw zawiera typy zdarzeń kondycji odpowiedzialne za pakowanie danych o stanie kondycji aplikacji i typów dostawców odpowiedzialnych za przetwarzanie tych danych. Zawiera również typy pomocnicze, które pomagają podczas zarządzania zdarzeniami kondycji.

Klasa WebFailureAuditEvent jest używana, gdy operacja zabezpieczeń kończy się niepowodzeniem. Przykładem jest nieudana autoryzacja adresu URL dla żądania sieci Web.

Domyślnie program ASP.NET jest skonfigurowany do zgłaszania WebFailureAuditEvent zdarzenia dla następujących funkcji:

Po wystąpieniu WebFailureAuditEvent zdarzenia ASP.NET monitorowanie kondycji zwiększa powiązane zdarzenia niepowodzenia inspekcji podniesione licznik wydajności, a następnie sprawdza healthMonitoring sekcję konfiguracji, aby określić, czy dostawcy subskrybują zdarzenie. Jeśli dostawcy subskrybują zdarzenie, ASP.NET wysyła do nich zdarzenie na potrzeby przetwarzania.

Uwaga

Aby wyświetlić licznik wydajności Zdarzenia niepowodzenia inspekcji podniesione w monitorze systemu (PerfMon), w oknie Dodawanie liczników wybierz ASP.NET z listy rozwijanej Obiekt wydajności , wybierz licznik wydajności Inspekcja zdarzeń niepowodzeń, a następnie kliknij przycisk Dodaj .

Uwaga

W większości przypadków będzie można użyć ASP.NET typów monitorowania kondycji zgodnie z implementacją i będzie kontrolować system monitorowania kondycji, określając wartości w healthMonitoring sekcji konfiguracji. Możesz również pochodzić z typów monitorowania kondycji w celu utworzenia własnych niestandardowych zdarzeń i dostawców. Aby zapoznać się z przykładem wyprowadzenia z WebFailureAuditEvent klasy, zobacz sekcję Przykład.

Uwagi dotyczące dziedziczenia

Podczas formatowania niestandardowych informacji o zdarzeniu do wyświetlenia zastąpij metodę FormatCustomEventDetails(WebEventFormatter) zamiast ToString metody . Pozwoli to uniknąć zastępowania lub manipulowania poufnymi informacjami o systemie.

Konstruktory

WebFailureAuditEvent(String, Object, Int32)

Inicjuje WebFailureAuditEvent nowe wystąpienie klasy przy użyciu podanych parametrów.

WebFailureAuditEvent(String, Object, Int32, Int32)

Inicjuje WebFailureAuditEvent nowe wystąpienie klasy przy użyciu podanych parametrów.

Właściwości

EventCode

Pobiera wartość kodu skojarzona ze zdarzeniem.

(Odziedziczone po WebBaseEvent)
EventDetailCode

Pobiera kod szczegółów zdarzenia.

(Odziedziczone po WebBaseEvent)
EventID

Pobiera identyfikator skojarzony ze zdarzeniem.

(Odziedziczone po WebBaseEvent)
EventOccurrence

Pobiera licznik reprezentujący liczbę przypadków wystąpienia zdarzenia.

(Odziedziczone po WebBaseEvent)
EventSequence

Pobiera liczbę zgłoszonych przez aplikację zdarzeń.

(Odziedziczone po WebBaseEvent)
EventSource

Pobiera obiekt, który zgłasza zdarzenie.

(Odziedziczone po WebBaseEvent)
EventTime

Pobiera czas, kiedy zdarzenie zostało podniesione.

(Odziedziczone po WebBaseEvent)
EventTimeUtc

Pobiera czas, kiedy zdarzenie zostało podniesione.

(Odziedziczone po WebBaseEvent)
Message

Pobiera komunikat opisujący zdarzenie.

(Odziedziczone po WebBaseEvent)
ProcessInformation

Pobiera informacje o procesie hostingu aplikacji ASP.NET.

(Odziedziczone po WebManagementEvent)
RequestInformation

Pobierz informacje skojarzone z żądaniem sieci Web.

(Odziedziczone po WebAuditEvent)

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
FormatCustomEventDetails(WebEventFormatter)

Zapewnia standardowe formatowanie informacji o zdarzeniu.

(Odziedziczone po WebBaseEvent)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
IncrementPerfCounters()

Zwiększa licznik wydajności zdarzeń niepowodzeń inspekcji.

MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
Raise()

Zgłasza zdarzenie, powiadamiając dowolnego skonfigurowanego dostawcę o wystąpieniu zdarzenia.

(Odziedziczone po WebBaseEvent)
ToString()

Formatuje informacje o zdarzeniach do celów wyświetlania.

(Odziedziczone po WebBaseEvent)
ToString(Boolean, Boolean)

Formatuje informacje o zdarzeniach do celów wyświetlania.

(Odziedziczone po WebBaseEvent)

Dotyczy

Zobacz też