HttpHandlerFactory & QueryString

R

Random

I'm using a set of HttpHandlers in my site to parse out the path and write
content based on information in that path, including the querystring.
Rather than have multiple entries in the web.config file, I thought I'd
instead create an HttpHandlerFactory that would analyze the path information
and then hand over the rest of the content generation to a specific
HttpHandler. My code is something like this...

Public Class ExportHandlerFactory
Implements IHttpHandlerFactory

Public Function GetHandler(ByVal context As HttpContext, ByVal
requestType As String, ByVal url As String, ByVal pathTranslated As String)
As IHttpHandler
Implements GetHandler

Select Case Path.GetFileNameWithoutExtension(url).ToLower()
Case "path-a"
Return New aPathHttpHandler
Case "path-b"
Return New bPathHttpHandler
Case Else
Return
PageParser.GetCompiledPageInstance("~/default.aspx",
context.Server.MapPath("~/default.aspx"), context)
End Select
End Function

Public Sub ReleaseHandler(ByVal handler As System.Web.IHttpHandler)
Implements System.Web.IHttpHandlerFactory.ReleaseHandler

End Sub
End Class

aPathHttpHandler and bPathHttpHandler are both handlers in the App_Code
directory. The problem with this approach is that aPathHttpHandler and
bPathHttpHander then have no querystring to read to analyze for creating
their content to write to the context.Response.

I've thought about just analyzing the querystring in the HttpHandlerFactory
and writing the querystring values to the context.Items collection, but I
want my HttpHandlers to be able to be standalone classes that won't depend
on the HttpHandlerFactory to do this.

Any inspiration or nuggets of wisdom on this would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top