在HttpModule中检测登录

本文关键字:登录 检测 HttpModule | 更新日期: 2023-09-27 18:19:33

我正在开发一个HttpModule,需要检测登录和注销过程。我该怎么做?

有什么想法吗?

提前感谢

在HttpModule中检测登录

这是你的意思吗?

    public void Init(HttpApplication context)
    {
        context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
    }
    void context_PreRequestHandlerExecute(object sender, EventArgs e)
    {
        HttpApplication app = (HttpApplication)sender;
        HttpContext context = app.Context;
        HttpResponse response = context.Response;
        if (IsLoginPage(context))
        {
            // ...
        }
        else if (IsLogoutPage(context))
        { 
            // ...
        }
    }