Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ermöglicht die Verarbeitung von HTTP-Webanforderungen durch einen benutzerdefinierten HttpHandler, der die IHttpHandler-Schnittstelle implementiert.
Namespace: System.Web
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Sub ProcessRequest ( _
context As HttpContext _
)
'Usage
Dim instance As IHttpHandler
Dim context As HttpContext
instance.ProcessRequest(context)
void ProcessRequest (
HttpContext context
)
void ProcessRequest (
HttpContext^ context
)
void ProcessRequest (
HttpContext context
)
function ProcessRequest (
context : HttpContext
)
Parameter
- context
Ein HttpContext-Objekt, das Verweise auf die systeminternen Serverobjekte bereitstellt (z. B. Request, Response, Session und Server), die für die Bearbeitung von HTTP-Anforderungen verwendet werden.
Hinweise
Platzieren Sie den benutzerdefinierten HttpHandler-Code in der virtuellen ProcessRequest-Methode, wie im folgenden Beispiel dargestellt.
Beispiel
Im folgenden Codebeispiel werden als Antwort auf eine Clientanforderung der Seite handler.aspx vier Textzeilen in den HTTP-Ausgabestream geschrieben. Alle Anforderungen für handler.aspx werden durch die MyHttpHandler-Klasse im Namespace HandlerExample bearbeitet, die in der Assembly HandlerTest.dll enthalten ist.
' 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).
'
'<configuration>
' <system.web>
' <httpHandlers>
' <add verb="*" path="handler.aspx" type="HandlerExample.MyHttpHandler,HandlerTest"/>
' </httpHandlers>
' </system.web>
'</configuration>
// 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>
*/
package HandlerExample ;
// Name this J# file HandlerTest.jsl and compile it with the
// command line: vjc /t:Library /r:System.Web.dll HandlerTest.jsl.
// Copy HandlerTest.dll to your \bin directory.
import System.Web.*;
public class MyHttpHandler implements IHttpHandler
{
// Override the ProcessRequest method.
public void ProcessRequest(HttpContext context)
{
context.get_Response().
Write("<H1>This is an HttpHandler Test.</H1>");
context.get_Response().
Write("<p>Your Browser:</p>");
context.get_Response().Write(("Type: "
+ context.get_Request().get_Browser().get_Type() + "<br>"));
context.get_Response().Write(("Version: "
+ context.get_Request().get_Browser().get_Version()));
} //ProcessRequest
// Override the IsReusable property.
/** @property
*/
public boolean get_IsReusable()
{
return true;
} //get_IsReusable
} //MyHttpHandler
/*
______________________________________________________________
To use this handler, include the following lines in a Web.config file.
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="handler.aspx"
type="HandlerTest.HandlerExample.MyHttpHandler,HandlerTest"/>
</httpHandlers>
</system.web>
</configuration>
*/
// Name this JScript file handlertest.js and compile it with the
// command line: jsc /t:library /r:system.web.dll handlertest.js
// Copy HandlerTest.dll to your bin directory.
import System.Web
package HandlerExample{
class MyHttpHandler implements IHttpHandler{
// Override the ProcessRequest method.
function IHttpHandler.ProcessRequest(context : HttpContext){
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.
function get IHttpHandler.IsReusable() : Boolean{
return true
}
}
}
//______________________________________________________________
//
// To use the above handler, use the following lines in a
// Web.config file (remove the comment markers)
//
//<configuration>
// <system.web>
// <httpHandlers>
// <add verb="*" path="handler.aspx" type="HandlerExample.MyHttpHandler,HandlerTest"/>
// </httpHandlers>
// </system.web>
//</configuration>
Plattformen
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
IHttpHandler-Schnittstelle
IHttpHandler-Member
System.Web-Namespace