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

D

Dima67

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)?
 
B

Bob Barrows

Dima67 said:
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.
******************************************************************
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top