IIS 6, custom isapifilter and a .NET 4 HttpHandlerRSS

1 reply

Last post Jun 12, 2013 02:09 PM by go81816

  • IIS 6, custom isapifilter and a .NET 4 HttpHandler

    Jun 11, 2013 06:03 PM|go81816|LINK

    Ok, so I have a homegrown isapifilter module that rewrites iis requests at the SF_NOTIFY_PREPROC_HEADERS stage using the HTTP_FILTER_PREPROC_HEADERS SetHeader function to change the "url" header.  Recently I started developing an HttpHandler c# dll to handle some of our requests.  Accessing my new HttpHandler directly works fine as well.

    The problem arises when I try to combine these two components.  When I try to use our homegrown isapifilter module to rewrite a request "url" to be the url of my new HttpHandler I receive a 403 Forbidden error.  On my Windows XP development machine with IIS 5.1, the rewrite works perfectly and I do not get the 403 Forbidden.  I see the error only on Windows Server 2003 R2 with IIS 6 (granted, I haven't tried it yet on any later version of IIS).

    I've tried changing the order of the isapi filter DLLs, putting our custom isapifilter before the asp.net 4.0 isapi filter dll to no avail.  I suspect something is running in the wrong order in the IIS pipeline or something, but I'm not sure how to go about even debugging why this is happening?  Any information would be very helpful.

    Thank you.

    httphandler asp.net4 filter isapi iis6

  • Re: IIS 6, custom isapifilter and a .NET 4 HttpHandler

    Jun 12, 2013 02:09 PM|go81816|LINK

    A further update:  I have learned that the problem is not limited .NET 4 HttpHandlers.  For example, I developed a simple .NET 4 aspx page and received the same 403 Forbidden response when I try to access that page using a url that is rewritten by our custom isapifilter.  So the problem is actually related strictly to .NET 4 modules only.  Rewriting to modules using earlier versions of .NET (v2.0, v3.0, etc) have no problem whatsoever.

    And after playing with IIS settings all morning on one server, I somehow managed to get urls rewritten by our custom isapifilter module to successfully rewrite to my aforementioned .NET 4 HttpHandler.  I'm not sure what I did (I changed many things from ASP.NET versions to Wildcard application maps) but I can still only rewrite urls for that .NET 4 HttpHandler only.  So whatever I changed it has to be an application specific setting.  I still cannot rewrite to my .NET 4 aspx page, and I would like to be able to, of course, replicate this to other servers/application scenarios.

    I suspect this must be related to the "Web Sites"-level ASP.NET_4.0.30319.0 ISAPI Filter introduced with .NET 4.  Does anyone know how a custom isapifilter should properly co-exist with this ASP.NET_4.0.30319.0 filter?  If I want to rewrite urls using a custom filter to potentially talk to .NET 4 modules is it important whether my filter is ahead of or behind the ASP.NET 4 filter in the isapifilter priority list? (Even though it didn't work for me to change it, I'm looking for "how things are supposed to work")

    Thanks again.