How to redirect HTTP request and then filter response with .Net 3.

Discussion in 'ASP General' started by Dima67, Aug 28, 2009.

  1. Dima67

    Dima67 Guest

    Hi,

    I am substituting an old ISAPI filter with a HttpModule using VS2008 and I
    got a set of problems.


    The old ISAPI filter works this way:

    1) It gets a request from a client browser

    1) then it figures out if this request has to be re-directed to a different
    web application. (It depends on request’s parameters)

    2) If this request should not be re-directed, then the ISAPI filter passes
    it to an ISAPI extension on the local server and filters the response before
    returning it to the client.

    3) If this request should be re-directed, then the ISAPI filter re-directs
    the request and filters its response before returning it to the client.


    To do that in Visual Studio 2008, I created a HttpModule, added a handler
    for HttpApplication.BeginRequest event and in the event handler I added a
    wrapping filter:

    public void On_BeginRequest(Object source, EventArgs e)
    {
    HttpApplication application = (HttpApplication)source;
    HttpContext context = application.Context;
    context.Response.Filter = new FilterStream(context.Response.Filter);
    }
    }

    The FilterStream does all the required filtering.

    But this approach does not work because of the following problems:

    Problem 1:

    Without specifying the wrapping filter, IIS properly resolves default
    document name (which is my ISAPI extension DLL) , passes requests to the
    ISAPI DLL and everything works fine.

    But when I assign the wrapping filter (i.e.
    Application.Context.Response.Filter = new …), IIS starts to verify existence
    of a resource specified in URL. The URL points to my ISAPI extension and,
    therefore, IIS does not find an existing file with such name.

    The error is:†A first chance exception of type 'System.Web.HttpException'
    occurred in System.Web.dll
    Additional information: File does not exist.â€.

    How to avoid such error? How to prevent IIS from checking existance of the
    resource when a wrapping filter is assigned to the request?



    Problem 2:

    I read that redirect requests reset existing chain of wrapping filters. I.e.
    a filter assigned to Application.Context.Response.Filter property will never
    be called when the page is redirected.

    But I need to get a response from the re-directed request and filter it. How
    it can be done with .Net framework 3.5 (VS2008)?

    --
    Best regards, Dima.
     
    Dima67, Aug 28, 2009
    #1
    1. Advertising

  2. Dima67

    Bob Barrows Guest

    Dima67 wrote:
    > Hi,
    >
    > I am substituting an old ISAPI filter with a HttpModule using VS2008

    ***canned wrong-newsgroup reply************************
    There was no way for you to know it (except maybe by browsing through some
    of the previous questions in this newsgroup before posting yours - always a
    recommended practice) , but this is a classic (COM-based) asp newsgroup.
    ASP.Net bears very little resemblance to classic ASP so, while you may be
    lucky enough to find a dotnet-knowledgeable person here who can answer your
    question, you can eliminate the luck factor by posting your question to a
    group where those dotnet-knowledgeable people hang out. I suggest
    microsoft.public.dotnet.framework.aspnet or the forums at www.asp.net.
    ******************************************************************


    --
    Microsoft MVP - ASP/ASP.NET - 2004-2007
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Aug 28, 2009
    #2
    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. Trevor Braun
    Replies:
    3
    Views:
    5,426
    Trevor Braun
    Apr 17, 2006
  2. Sal
    Replies:
    1
    Views:
    688
  3. Secret Squirrel
    Replies:
    5
    Views:
    1,107
    Secret Squirrel
    Oct 12, 2005
  4. Replies:
    0
    Views:
    304
  5. David Morgan
    Replies:
    1
    Views:
    331
    raj chahal
    Feb 24, 2006
Loading...

Share This Page