【问题标题】:Handling Forms Authentication events in a HTTP Module在 HTTP 模块中处理表单身份验证事件
【发布时间】:2014-08-28 09:07:04
【问题描述】:

我正在通过实现 IHttpModule 创建一个 HTTP 模块,并且我想处理由 Forms Authentication 模块引发的 Authenticate 事件。

文档仅说明如何在 Global.asax 中处理此事件,我如何在我的 HTTP 模块中处理此事件?

【问题讨论】:

    标签: c# asp.net .net forms-authentication httpmodule


    【解决方案1】:

    您可以处理传递给您的IHttpModule 实现的Init 方法的HttpApplicationAuthenticateRequest 事件:

    // 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 有一个使用自定义 HttpModule 的 Web API 中的基本身份验证示例,可能会有所帮助。

    【讨论】:

    • 啊 - 文档确实解释了在 AuthenticateRequest 事件期间引发了 Authenticate 事件,但我忽略了这一点 - 谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-09
    • 1970-01-01
    • 2015-05-19
    • 1970-01-01
    相关资源
    最近更新 更多