I've got an HttpModule in my application that hooks into the FormsAuthenticationModule's Authenticate event with the following code:
public void Init(HttpApplication context)
{
FormsAuthenticationModule faModule =
(FormsAuthenticationModule)context.Modules["FormsAuthentication"];
faModule.Authenticate +=
new FormsAuthenticationEventHandler(faModule_Authenticate);
}
Unfortunately, the call to context.Modules fails because the app needs to run in a medium-trust environment. Is there another way that I can hook into this event?
That's a tough one - you can't even access the Modules collection from within your Global application file.
You could try calling your custom code from the AuthenticateRequest handler in Global:
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
// Call your module's code here..
}
You can't grab your custom module from the collection, either, so you'd need a static reference to your module's library.
Other than granting the AspNetHostingPermission (as detailed for other permissions here) to your site in the machine level web.config, I'm out of ideas!