Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > How to redirect HTTP request and then filter response with .Net 3.

Thread Tools

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

Posts: n/a

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 (VS200?

Best regards, Dima.

Reply With Quote
Bob Barrows
Posts: n/a
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
************************************************** ****************

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

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How do I submit a form and then do a response.redirect? Trevor Braun ASP .Net 3 04-17-2006 02:33 PM
HTTP 302 (Response.Redirect) to mms:// URL gives error, to http:// is ok. David Morgan ASP General 1 02-24-2006 01:33 PM
Help. SessionID is x then y then x then y ASP General 0 09-03-2005 03:02 PM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM