Found the following at:
http://msdn.microsoft.com/library/de...erfactory.asp:
You can generate a new handler instance for ea. HTTP request by creating a class
that implements the IHttpHandlerFactory interface. In the fol. example, a
HttpHandler factory is used to create different handlers for an HTTP GET request and
an HTTP POST request. One of the handlers is an instance of a synchronous handler;
the other handler is an instance an asynchronous handler.
Code:
Imports System
Imports System.Web
Namespace Handlers
Class HandlerFactory
Implements IHttpHandlerFactory
Public Function GetHandler(ByVal context As HttpContext, _
ByVal reqType As String, _
ByVal url As [String], _
ByVal pathXlated As [String] _
) As IHttpHandler _
Implements IHttpHandlerFactory.GetHandler
Dim handlerToReturn As IhttpHandler
With context.Request.RequestType
If "get" = .ToLower() Then
handlerToReturn = New SynchHandler()
Else
If "post" = .ToLower() Then
handlerToReturn = New AsynchHandler()
Else
handlerToReturn = Nothing
End If
End If
End With
Return handlerToReturn
End Function
Public Sub ReleaseHandler(ByVal handler As IhttpHandler _
) Implements IHttpHandlerFactory.ReleaseHandler
End Sub
Public ReadOnly Property IsReusable() As Boolean
Get
' To enable pooling, return True here.
' This keeps the handler in memory.
Return False
End Get
End Property
End Class
End Namespace
Register your custom HttpHandler factory by creating an entry in Web.config as follows:
Code:
<configuration>
<system.web>
<httpHandlers>
<add verb="GET,POST" path="*.MyFactory" type="Handlers.HandlerFactory, Handlers" />
</httpHandlers>
</system.web>
</configuration>
What is the meaning of the â[String]â in the declaration of Public Function GetHandler()?