WebFailureAuditEvent Klasa
Definicja
Ważny
Niektóre informacje dotyczą produktów przedpremierowych, które mogą zostać znacznie zmodyfikowane przed premierą. Microsoft nie udziela żadnych gwarancji, ani wyraźnych, ani domniemanych, dotyczących informacji podanych tutaj.
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
- Pochodny
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:
Autoryzacja pliku. ASP.NET próbuje autoryzacji pliku tylko wtedy, gdy tożsamość systemu Windows jest skojarzona z żądaniem. Powiązany kod inspekcji zdarzeń to AuditFileAuthorizationFailure.
Autoryzacja adresu URL. Zarządza to nieautoryzowanymi próbami uzyskania dostępu do zasobu adresu URL. Nieudane próby przez anonimowego użytkownika nie są poddawane inspekcji, ponieważ niepowodzenie uwierzytelniania anonimowego jest dopuszczalne w większości przypadków. Powiązany kod inspekcji zdarzeń to AuditUrlAuthorizationFailure.
Ogólne nieobsługiwane lub nieobsługiwane warunki zabezpieczeń. Poniżej znajduje się lista kodów zdarzeń związanych z następującymi warunkami:
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.
Notatki dla spadkobierców
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.
Konstruktorów
| Nazwa | Opis |
|---|---|
| WebFailureAuditEvent(String, Object, Int32, Int32) |
Inicjuje WebFailureAuditEvent nowe wystąpienie klasy przy użyciu podanych parametrów. |
| WebFailureAuditEvent(String, Object, Int32) |
Inicjuje WebFailureAuditEvent nowe wystąpienie klasy przy użyciu podanych parametrów. |
Właściwości
| Nazwa | Opis |
|---|---|
| EventCode |
Pobiera wartość kodu skojarzona ze zdarzeniem. (Dziedziczone od WebBaseEvent) |
| EventDetailCode |
Pobiera kod szczegółów zdarzenia. (Dziedziczone od WebBaseEvent) |
| EventID |
Pobiera identyfikator skojarzony ze zdarzeniem. (Dziedziczone od WebBaseEvent) |
| EventOccurrence |
Pobiera licznik reprezentujący liczbę przypadków wystąpienia zdarzenia. (Dziedziczone od WebBaseEvent) |
| EventSequence |
Pobiera liczbę zgłoszonych przez aplikację zdarzeń. (Dziedziczone od WebBaseEvent) |
| EventSource |
Pobiera obiekt, który zgłasza zdarzenie. (Dziedziczone od WebBaseEvent) |
| EventTime |
Pobiera czas, kiedy zdarzenie zostało podniesione. (Dziedziczone od WebBaseEvent) |
| EventTimeUtc |
Pobiera czas, kiedy zdarzenie zostało podniesione. (Dziedziczone od WebBaseEvent) |
| Message |
Pobiera komunikat opisujący zdarzenie. (Dziedziczone od WebBaseEvent) |
| ProcessInformation |
Pobiera informacje o procesie hostingu aplikacji ASP.NET. (Dziedziczone od WebManagementEvent) |
| RequestInformation |
Pobierz informacje skojarzone z żądaniem sieci Web. (Dziedziczone od WebAuditEvent) |
Metody
| Nazwa | Opis |
|---|---|
| Equals(Object) |
Określa, czy dany obiekt jest taki sam, jak bieżący obiekt. (Dziedziczone od Object) |
| FormatCustomEventDetails(WebEventFormatter) |
Zapewnia standardowe formatowanie informacji o zdarzeniu. (Dziedziczone od WebBaseEvent) |
| GetHashCode() |
Służy jako domyślna funkcja skrótu. (Dziedziczone od Object) |
| GetType() |
Type Pobiera bieżące wystąpienie. (Dziedziczone od Object) |
| IncrementPerfCounters() |
Zwiększa licznik wydajności zdarzeń niepowodzeń inspekcji. |
| MemberwiseClone() |
Tworzy płytkią kopię bieżącego Objectelementu . (Dziedziczone od Object) |
| Raise() |
Zgłasza zdarzenie, powiadamiając dowolnego skonfigurowanego dostawcę o wystąpieniu zdarzenia. (Dziedziczone od WebBaseEvent) |
| ToString() |
Formatuje informacje o zdarzeniach do celów wyświetlania. (Dziedziczone od WebBaseEvent) |
| ToString(Boolean, Boolean) |
Formatuje informacje o zdarzeniach do celów wyświetlania. (Dziedziczone od WebBaseEvent) |