DefaultHttpHandler クラス

定義

既定の HTTP ハンドラーのプロパティとメソッドを表します。

public ref class DefaultHttpHandler : System::Web::IHttpAsyncHandler
public class DefaultHttpHandler : System.Web.IHttpAsyncHandler
type DefaultHttpHandler = class
    interface IHttpAsyncHandler
    interface IHttpHandler
Public Class DefaultHttpHandler
Implements IHttpAsyncHandler
継承
DefaultHttpHandler
実装

次のコード例では、 クラスから派生してカスタマイズされた HTTP ハンドラーを実装する方法を DefaultHttpHandler 示します。

public class AsyncDefaultHttpHandler : DefaultHttpHandler
{
    private HttpContext _context;

    public override IAsyncResult BeginProcessRequest(
      HttpContext context, AsyncCallback callback, object state)
    {
        AsyncResultSample ar = new AsyncResultSample(callback, state);
        _context = context;

        return ar;
    }

    public override void EndProcessRequest(IAsyncResult result)
    {
        _context.Response.Write("EndProcessRequest called.");
    }

    // This method should not be called asynchronously.
    public override void ProcessRequest(HttpContext context)
    {
        throw new InvalidOperationException(
                  "Asynchronous processing failed.");
    }

    // Enables pooling when set to true
    public override bool IsReusable
    {
        get { return true; }
    }
}

// Tracks state between the begin and end calls.
class AsyncResultSample : IAsyncResult
{
    private AsyncCallback callback = null;
    private Object asyncState;
    private Boolean isCompleted;

    internal AsyncResultSample(AsyncCallback cb, Object state)
    {
        this.callback = cb;
        asyncState = state;
        isCompleted = false;
    }

    public object AsyncState
    {
        get
        {
            return asyncState;
        }
    }

    public bool CompletedSynchronously
    {
        get
        {
            return false;
        }
    }

    public WaitHandle AsyncWaitHandle
    {
        get
        {
            throw new InvalidOperationException(
                      "ASP.NET should not use this property .");
        }
    }

    public bool IsCompleted
    {
        get
        {
            return isCompleted;
        }
    }

    internal void SetCompleted()
    {
        isCompleted = true;
        if (callback != null)
        {
            callback(this);
        }
    }
}
Public Class defaulthttpexampleVB
    Inherits DefaultHttpHandler

    Private _context As HttpContext

    Public Overrides Function BeginProcessRequest _
        (ByVal context As HttpContext, _
         ByVal callback As AsyncCallback, _
         ByVal state As Object) As IAsyncResult

        Dim ar As New AsyncResultSample(callback, state)
        _context = context

        Return (ar)
    End Function

    Public Overrides Sub EndProcessRequest(ByVal result As IAsyncResult)
        _context.Response.Write("EndProcessRequest called.")
    End Sub

    ' This method should not be called asynchronously.
    Public Overrides Sub ProcessRequest(ByVal context As HttpContext)
        Throw New InvalidOperationException _
          ("Asynchronous processing failed.")
    End Sub

    ' Enables pooling when set to true
    Public Overrides ReadOnly Property IsReusable() As Boolean
        Get
            Return True
        End Get
    End Property
End Class

' Tracks state between the begin and end calls.
Class AsyncResultSample
    Implements IAsyncResult
    Private callback As AsyncCallback = Nothing
    Private _asyncState As Object
    Private _isCompleted As Boolean

    Friend Sub New(ByVal cb As AsyncCallback, ByVal state As Object)
        Me.callback = cb
        _asyncState = state
        _isCompleted = False
    End Sub

    Public ReadOnly Property AsyncState() As Object _
      Implements IAsyncResult.AsyncState
        Get
            Return _asyncState
        End Get
    End Property

    Public ReadOnly Property CompletedSynchronously() _
      As Boolean Implements IAsyncResult.CompletedSynchronously
        Get
            Return False
        End Get
    End Property

    Public ReadOnly Property AsyncWaitHandle() _
      As WaitHandle Implements IAsyncResult.AsyncWaitHandle
        Get
            Throw New InvalidOperationException _
              ("ASP.NET should not use this property .")
        End Get
    End Property

    Public ReadOnly Property IsCompleted() _
      As Boolean Implements IAsyncResult.IsCompleted
        Get
            Return IsCompleted
        End Get
    End Property

    Friend Sub SetCompleted()
        _isCompleted = True
        If (callback <> Nothing) Then
            callback(Me)
        End If
    End Sub
End Class

注釈

DefaultHttpHandler要求インターセプトがインターネット インフォメーション サービス (IIS) 6.0 を介して構成されていて、要求された拡張機能に明示的なバインドが適用されていない場合、オブジェクトは HTTP パイプライン内の受信要求をインターセプトします。

要求インターセプトは、IIS 6.0 で導入されたワイルドカード アプリケーション マッピング機能を使用して設定できます。

クラスは DefaultHttpHandler 、 インターフェイスを IHttpAsyncHandler 実装して非同期の要求処理を提供します。 HTTP ハンドラーの一般的な情報については、「 HTTP ハンドラーと HTTP モジュールの概要」を参照してください。 さらに、詳細については、次を参照してください。

クラスは、 クラスから DefaultHttpHandler 派生して、要求のカスタマイズされた処理を提供できます。 から DefaultHttpHandler 派生した非同期 HTTP ハンドラーは、 メソッドを BeginProcessRequest オーバーライドして要求の処理方法を変更できます。

では DefaultHttpHandler 、ASP.NET エラーは使用されません。 IIS エラーまたは適切な ISAPI カスタム エラー メカニズムを使用する既存のコンテンツは、変更されずに機能します。

コンストラクター

DefaultHttpHandler()

DefaultHttpHandler クラスの新しいインスタンスを初期化します。

プロパティ

Context

現在の DefaultHttpHandler オブジェクトに関連付けられているコンテキストを取得します。

ExecuteUrlHeaders

要求と共に転送する要求ヘッダーと要求値のコレクションを取得します。

IsReusable

DefaultHttpHandler クラスの現在のインスタンスを別の要求が使用できるかどうかを示すブール値を取得します。

メソッド

BeginProcessRequest(HttpContext, AsyncCallback, Object)

HTTP ハンドラーの非同期の呼び出しを開始します。

EndProcessRequest(IAsyncResult)

非同期処理の終了メソッドを提供します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
OnExecuteUrlPreconditionFailure()

実行前の状態が原因で DefaultHttpHandler オブジェクトが要求を処理できない場合に呼び出されます。

OverrideExecuteUrlPath()

現在の要求の対象 URL をオーバーライドします。

ProcessRequest(HttpContext)

DefaultHttpHandler オブジェクトを有効にして、HTTP Web 要求を処理します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください