HttpHandlerFactory & QueryString

Discussion in 'ASP .Net' started by Random, Nov 29, 2007.

  1. Random

    Random Guest

    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.
     
    Random, Nov 29, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. suzy
    Replies:
    3
    Views:
    3,141
  2. Axel Dahmen

    Pack QueryString

    Axel Dahmen, Jun 29, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    550
    Axel Dahmen
    Jun 29, 2003
  3. Mehdi
    Replies:
    6
    Views:
    36,222
    sloan
    Apr 6, 2006
  4. =?Utf-8?B?d2FsdGVy?=

    HttpHandlerFactory is not always called in IIS

    =?Utf-8?B?d2FsdGVy?=, Jun 7, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    670
    =?Utf-8?B?d2FsdGVy?=
    Jun 7, 2006
  5. Adeel Ahmad
    Replies:
    1
    Views:
    578
    Anthony Jones
    Mar 7, 2006
Loading...

Share This Page