0

I'm creating a HTTP module by implementing IHttpModule and I'd like to handle the Authenticate event, raised by the Forms Authentication module.

The documentation only states how to handle this event from within Global.asax, how can I handle this event from within my HTTP module?

1 Answer 1

1

You can handle the AuthenticateRequest event of the HttpApplication that is passed to the Init method of your IHttpModule implementation:

// IHttpModule.Init
public void Init(HttpApplication context)
{
    // subscribe to the AuthenticateRequest event
    context.AuthenticateRequest += this.onApplicationAuthenticateRequest;
}

private void onApplicationAuthenticateRequest(object sender, EventArgs e)
{
    // your code goes here
}

This article has an example of the basic authentication in Web API which uses custom HttpModule, might be helpful.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah - the documentation does explain that the Authenticate event is raised during the AuthenticateRequest event, but I overlooked that - thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.