IHttpHandler.IsReusable 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得值,指出另一個要求是否可以使用 IHttpHandler 執行個體。
public:
property bool IsReusable { bool get(); };
public bool IsReusable { get; }
member this.IsReusable : bool
Public ReadOnly Property IsReusable As Boolean
屬性值
如果 IHttpHandler 執行個體可重複使用,則為 true
,否則為 false
。
範例
下列程式碼範例會將四行文字寫入 HTTP 輸出資料流程,以回應名為 handler.aspx 之頁面的用戶端要求。 handler.aspx 的所有要求都是由 MyHttpHandler
包含在元件HandlerTest.dll命名空間中的 HandlerExample
類別提供服務。
// 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"/>
備註
您明確將 屬性設定 IsReusable 為 true
或 false
透過程式碼提供,以覆寫 IsReusable getter) (屬性存取子。