Share via


WebRequestInformation 클래스

정의

현재 웹 요청에 대한 정보를 제공합니다.

public ref class WebRequestInformation sealed
public sealed class WebRequestInformation
type WebRequestInformation = class
Public NotInheritable Class WebRequestInformation
상속
WebRequestInformation

예제

다음 코드 예제를 사용 하는 사용자 지정 이벤트를 구현 하는 방법을 보여 줍니다는 WebRequestInformation 형식입니다.

이 사용자 지정 이벤트를 사용 하는 ASP.NET을 사용 하도록 설정 하는 구성 파일의 일부는도 표시 됩니다.

사용자 지정 이벤트가 발생 하는지 적절 한 시기, 이벤트가 발생할 때 해당 하는 시스템 상태를 대체는 수를 확인 합니다.

<healthMonitoring  
  heartBeatInterval="0" enabled="true">  

  <profiles>  
    <add name="Custom"   
      minInstances="1"   
      maxLimit="Infinite"   
      minInterval="00:00:00" />  
  </profiles>  

  <eventMappings>  

    <add   
      name="SampleWebRequestInformation"   
      type="SamplesAspNet.SampleWebRequestInformation,webrequestinformation,Version=1.0.1782.28745, Culture=neutral, PublicKeyToken=79955d9b8521c250,processorArchitecture=MSIL" />  

  </eventMappings>  

  <rules>  

    <add name="Custom Web Request Info Event"   
      eventName="SampleWebRequestInformation"   
      provider="EventLogProvider"  
      profile="Custom" />  

  </rules>  

</healthMonitoring>  

using System;
using System.Text;
using System.Web;
using System.Web.Management;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SamplesAspNet
{
    // Implements a custom WebRequestEvent that uses
    // WebRequestInformation. 
    public class SampleWebRequestInformation :
        WebRequestEvent
    {
        private StringBuilder eventInfo;

        // Instantiate events identified 
        // only by their event code.
        public SampleWebRequestInformation(string msg,
            object eventSource, int eventCode):
        base(msg, eventSource, eventCode)
        {
            // Perform custom initialization.
            eventInfo = new StringBuilder();
            eventInfo.Append(string.Format(
                "Event created at: {0}",
                EventTime.ToString()));
        }

        // Instantiate events identified by 
        // their event code.and related 
        // event detailed code.
        public SampleWebRequestInformation(string msg,
            object eventSource, int eventCode,
            int eventDetailCode)
            :
            base(msg, eventSource,
            eventCode, eventDetailCode)
        {
            // Perform custom initialization.
            eventInfo = new StringBuilder();
            eventInfo.Append(string.Format(
                "Event created at: {0}",
                EventTime.ToString()));
        }


        // Raises the event.
        public override void Raise()
        {
            // Perform custom processing. 
            eventInfo.Append(string.Format(
                "Event raised at: {0}",
               EventTime.ToString()));
            // Raise the event.
            base.Raise();
        }

        // Get the request path.
        public string GetRequestPath()
        {
            // Get the request path.
            return (string.Format(
                "Request path: {0}",
                RequestInformation.RequestPath));
        }

        // Get the request URL.
        public string GetRequestUrl()
        {
            // Get the request URL.
            return (string.Format(
                "Request URL: {0}",
                RequestInformation.RequestUrl));
        }

        // Get the request user host address.
        public string GetRequestUserHostAdddress()
        {
            // Get the request user host address.
            return (string.Format(
                "Request user host address: {0}",
                RequestInformation.UserHostAddress));
        }

        // Get the request principal.
        public string GetRequestPrincipal()
        {
            // Get the request principal.
            return (string.Format(
                "Request principal name: {0}",
                RequestInformation.Principal.Identity.Name));
        }


        // Formats Web request event information.
        public override void FormatCustomEventDetails(
         WebEventFormatter formatter)
        {

            // Add custom data.

            formatter.AppendLine("");
            formatter.AppendLine(
                "Custom Request Information:");

            formatter.IndentationLevel += 1;

            // Display the request information obtained 
            // using the WebRequestInformation object.
            formatter.AppendLine(GetRequestPath());
            formatter.AppendLine(GetRequestUrl());
            formatter.AppendLine(GetRequestUserHostAdddress());
            formatter.AppendLine(GetRequestPrincipal());

            formatter.IndentationLevel -= 1;

            formatter.AppendLine(eventInfo.ToString());
        }

    }
}
Imports System.Text
Imports System.Web
Imports System.Web.Management
Imports System.Web.UI
Imports System.Web.UI.WebControls


' Implements a custom WebRequestEvent that uses
' WebRequestInformation. 

Public Class SampleWebRequestInformation
   Inherits WebRequestEvent
   Private eventInfo As StringBuilder
   
   
   ' Instantiate 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.
        eventInfo = New StringBuilder()
        eventInfo.Append(String.Format( _
        "Event created at: {0}", EventTime.ToString()))
    End Sub
   
   
   ' Instantiate events identified by 
   ' their event code.and related 
   ' event detailed code.
    Public Sub New(ByVal msg As String, _
    ByVal eventSource As Object, _
    ByVal eventCode As Integer, _
    ByVal eventDetailCode As Integer)
        MyBase.New(msg, eventSource, _
        eventCode, eventDetailCode)
        ' Perform custom initialization.
        eventInfo = New StringBuilder()
        eventInfo.Append(String.Format( _
        "Event created at: {0}", EventTime.ToString()))
    End Sub
   
   
   ' Raises the event.
   Public Overrides Sub Raise()
      ' Perform custom processing. 
        eventInfo.Append(String.Format( _
        "Event raised at: {0}", EventTime.ToString()))
      ' Raise the event.
      MyBase.Raise()
   End Sub
   
   ' Get the request path.
   Public Function GetRequestPath() As String
      ' Get the request path.
        Return String.Format( _
        "Request path: {0}", RequestInformation.RequestPath)
   End Function 'GetRequestPath
   
   ' Get the request URL.
   Public Function GetRequestUrl() As String
      ' Get the request URL.
        Return String.Format("Request URL: {0}", _
        RequestInformation.RequestUrl)
   End Function 'GetRequestUrl
   
   ' Get the request user host address.
   Public Function GetRequestUserHostAdddress() As String
      ' Get the request user host address.
        Return String.Format( _
        "Request user host address: {0}", _
        RequestInformation.UserHostAddress)
   End Function 'GetRequestUserHostAdddress
   
   ' Get the request principal.
   Public Function GetRequestPrincipal() As String
      ' Get the request principal.
        Return String.Format( _
        "Request principal name: {0}", _
        RequestInformation.Principal.Identity.Name)
   End Function 'GetRequestPrincipal
   
   ' Formats Web request event information.
    Public Overrides Sub FormatCustomEventDetails( _
    ByVal formatter As WebEventFormatter)

        ' Add custom data.
        formatter.AppendLine("")
        formatter.AppendLine("Custom Request Information:")

        formatter.IndentationLevel += 1

        ' Display the request information obtained 
        ' using the WebRequestInformation object.
        formatter.AppendLine(GetRequestPath())
        formatter.AppendLine(GetRequestUrl())
        formatter.AppendLine(GetRequestUserHostAdddress())
        formatter.AppendLine(GetRequestPrincipal())
        formatter.IndentationLevel -= 1

        formatter.AppendLine(eventInfo.ToString())
    End Sub

End Class

설명

ASP.NET 상태 모니터링 프로덕션와 운영 스태프를 배포 된 웹 애플리케이션을 관리할 수 있습니다. System.Web.Management 네임 스페이스 애플리케이션 상태 데이터 및이 데이터 처리를 담당 하는 공급자 형식이 패키징 담당 상태 이벤트 형식을 포함 합니다. 또한 상태 이벤트를 관리 하는 동안 유용한 지 원하는 형식을 포함 합니다.

인스턴스를 WebRequestInformation 클래스를 사용 하 여 얻은 정보를 포함 합니다 WebRequestEvent, WebAuditEvent, WebErrorEvent, 또는 WebRequestErrorEvent 형식.

애플리케이션에이 형식에서 제공 하는 보호 된 정보를 액세스 하는 적절 한 권한이 필요 합니다.

참고

대부분의 경우에 구현 된 대로 ASP.NET 상태 모니터링 유형을 사용할 수 없게 됩니다 및에서 값을 지정 하 여 상태 모니터링 시스템을 제어 하는 healthMonitoring 구성 섹션입니다. 사용자 고유의 사용자 지정 이벤트 및 공급자 상태 모니터링 형식에서 파생할 수 있습니다. 사용자 지정 이벤트 클래스를 만드는 예제를이 항목에 제공 된 예제를 참조 하세요.

속성

Principal

웹 요청과 관련된 관리되는 코드 보안 주체의 인스턴스를 가져옵니다.

RequestPath

웹 요청의 실제 경로를 가져옵니다.

RequestUrl

요청의 논리 경로를 가져옵니다.

ThreadAccountName

코드를 실행하고 있는 사용자의 Windows 로그온 이름을 나타내는 문자열을 가져옵니다.

UserHostAddress

사용자의 호스트 주소를 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
FormatToString(WebEventFormatter)

웹 요청 정보의 서식을 지정합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보