IHttpHandler.IsReusable プロパティ

定義

別の要求で IHttpHandler インスタンスを使用できるかどうかを示す値を取得します。

public:
 property bool IsReusable { bool get(); };
public bool IsReusable { get; }
member this.IsReusable : bool
Public ReadOnly Property IsReusable As Boolean

プロパティ値

Boolean

IHttpHandler インスタンスが再利用できる場合は true。それ以外の場合は false

次のコード例では、handler.aspx という名前のページに対するクライアント要求に応答して、HTTP 出力ストリームに 4 行のテキストを書き込みます。 handler.aspx のすべての要求は、アセンブリ HandlerTest.dllに含まれる名前空間HandlerExampleのクラスによってMyHttpHandler処理されます。

// Name this C# file HandlerTest.cs and compile it with the
// command line: csc /t:library /r:System.Web.dll HandlerTest.cs.
// Copy HandlerTest.dll to your \bin directory.

using System.Web;

namespace HandlerExample
{
   public class MyHttpHandler : IHttpHandler
   {
      // Override the ProcessRequest method.
      public void ProcessRequest(HttpContext context)
      {
         context.Response.Write("<H1>This is an HttpHandler Test.</H1>");
         context.Response.Write("<p>Your Browser:</p>");
         context.Response.Write("Type: " + context.Request.Browser.Type + "<br>");
         context.Response.Write("Version: " + context.Request.Browser.Version);
      }

      // Override the IsReusable property.
      public bool IsReusable
      {
         get { return true; }
      }
   }
}

/*
______________________________________________________________

To use this handler, include the following lines in a Web.config file.

<configuration>
   <system.web>
      <httpHandlers>
         <add verb="*" path="handler.aspx" type="HandlerExample.MyHttpHandler,HandlerTest"/>
      </httpHandlers>
   </system.web>
</configuration>
*/
' Name this Visual Basic file HandlerTest.vb and compile it with the
' command line: vbc /target:library /r:System.Web.dll HandlerTest.vb.
' Copy HandlerTest.dll to your \bin directory.
Imports System.Web

Namespace HandlerExample
    
    Public Class MyHttpHandler
        Implements IHttpHandler
        
        ' Override the ProcessRequest method.
        Public Sub ProcessRequest(context As HttpContext) _
        Implements IHttpHandler.ProcessRequest
        
            context.Response.Write("<H1>This is an HttpHandler Test.</H1>")
            context.Response.Write("<p>Your Browser:</p>")
            context.Response.Write("Type: " & context.Request.Browser.Type & "<br>")
            context.Response.Write("Version: " & context.Request.Browser.Version)
        End Sub
        
        ' Override the IsReusable property.        
        Public ReadOnly Property IsReusable() As Boolean _
        Implements IHttpHandler.IsReusable
        
            Get
                Return True
            End Get
        End Property
    End Class
End Namespace

'______________________________________________________________
'
' To use this handler, include the following lines in a
' Web.config file (be sure to remove the comment markers).
'
'         <add verb="*" path="handler.aspx" type="HandlerExample.MyHttpHandler,HandlerTest"/>

注釈

プロパティ アクセサー (getter) をIsReusableオーバーライドするtrue、指定したコードにプロパティを明示的にIsReusable設定しますfalse

適用対象