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
2) then it figures out if this request has to be re-directed to a different
web application. (It depends on request’s parameters)
3) 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.
4) 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).
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
2) then it figures out if this request has to be re-directed to a different
web application. (It depends on request’s parameters)
3) 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.
4) 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).