WebRequestInformation クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > WebRequestInformation クラスの意味・解説 

WebRequestInformation クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

現在の Web 要求に関する情報提供します

名前空間: System.Web.Management
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public NotInheritable Class
 WebRequestInformation
Dim instance As WebRequestInformation
public sealed class WebRequestInformation
public ref class WebRequestInformation sealed
public final class WebRequestInformation
public final class 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>
Imports System
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 'New
   
   
   ' 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 'New
   
   
   ' 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 'Raise
   
   ' 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 'FormatCustomEventDetails
 

End Class 'SampleWebRequestInformation


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());

        }


    }
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
  System.Web.Management.WebRequestInformation
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebRequestInformation メンバ
System.Web.Management 名前空間
WebRequestEvent クラス
その他の技術情報
healthMonitoring 要素 (ASP.NET 設定スキーマ)


このページでは「.NET Framework クラス ライブラリ リファレンス」からWebRequestInformation クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からWebRequestInformation クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からWebRequestInformation クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「WebRequestInformation クラス」の関連用語

WebRequestInformation クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



WebRequestInformation クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS