Hey guys / gals,
I will try to be as specific as I can be. I inherited a very antiquated C++ ISAPI filter that secures a classic ASP website and was tasked with the job of creating an HTTPModule to directly replace it.
First I hooked into the OnPreRequestHandlerExecute event. I then successfully recreated the calls to the stored procs that the original ISAPI filter made. Those calls return a statusCode which I toss into a CASE statement and depending on the status code, set a "redirection" string variable (sUrl). For example statusCode 15 will set sUrl to "/Session/Login.asp". This all works successfully.
The next step is the actual "redirect" of the page. In C++ the module was doing the following:
Headers.push_back(HeadersList::value_type("url", "/Session/Errors/SecurIDRequired.asp"));
I am attempting to recreate this functionality by using the following:
HttpContext.Current.RewritePath(sUrl);
This works 100% for all classic asp pages. The problem creeps up when the user trys to access "http://somedomain.com/Blah.jpg. The module successfully runs, sets the proper statusCode of 15, and the RewritePath method is called, but does not rewrite the URL to the login page. The same thing happens for any non classic ASP page.
So I started looking at other options instead of RewritePath and looked at TransferRequest. This looked promising so I changed the code to:
HttpContext.Current.Server.TransferRequest(sUrl, true);
This now routes all requested file types to the login page but bizarre things occur. First off I get the following client side errors in FireBug:
syntax error https://somedomain.com/JS/jQuery/jquery.js Line 2
... some other javascript errors that revolve around jQuery. I look at the Net panel, and it successfully loaded the jQuery library so I am at a loss with this (this does not happen with the RewritePath method).
Finally, I attempted to use good old Server.Transfer and got this server side error:
No http handler was found for request type 'GET'
Phew! I hope my explanation was adequate :)
I guess my real question is this, what is the best way to accomplish what I am attempting to accomplish. I feel as though the RewritePath method is the best, any tips would be greatly appreciated.
Cheers!
EDIT:
The handlers contained within the web.config are as follows:
<httpHandlers>
<remove verb="*" path="*.asmx" />
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpHandlers>