How can I connect to the current FormsAuthenticationModule in a medium trust environment?

I have an HttpModule in my application that catches the FormsAuthenticationModule 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 application must run in a medium of trust. Is there any other way by which I can connect to this event?

+3
source share
1 answer

This is a tricky question: you cannot even access the module collection in your global application file.

AuthenticateRequest Global:

protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
    // Call your module code here..
}

, .

AspNetHostingPermission ( ) web.config, !

+3

All Articles