This documentation is archived and is not being maintained.

IHttpHandlerFactory::GetHandler Method

Returns an instance of a class that implements the IHttpHandler interface.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

IHttpHandler^ GetHandler(
	HttpContext^ context, 
	String^ requestType, 
	String^ url, 
	String^ pathTranslated
)

Parameters

context
Type: System.Web::HttpContext

An instance of the HttpContext class that provides references to intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.

requestType
Type: System::String

The HTTP data transfer method (GET or POST) that the client uses.

url
Type: System::String

The RawUrl of the requested resource.

pathTranslated
Type: System::String

The PhysicalApplicationPath to the requested resource.

Return Value

Type: System.Web::IHttpHandler
A new IHttpHandler object that processes the request.

The following code example demonstrates how to create custom handler objects in response to a client request. The example has two parts:

  • A handler factory class.

  • A Web.config file excerpt.

The first part of the example shows how to create custom handler objects in response to a client request for a page named either abc.aspx or xyz.aspx. The handler factory class named hwf creates the appropriate handler object depending on the page requested.

No code example is currently available or this language may not be supported.

The second part of the example shows a Web.config file excerpt. To use the above handler factory, add the following lines to the Web.config file.

<configuration> 
  <system.web> 
    <httpHandlers> 
      <add verb="*" path="abc.aspx" type="test.MyFactory,HandlerFactoryTest" /> 
      <add verb="*" path="xyz.aspx" type="test.MyFactory,HandlerFactoryTest" /> 
    </httpHandlers> 
  </system.web>
</configuration> 

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: