检测HttpModule中的登录

时间:2012-01-05 06:21:23

标签: c# asp.net login httpmodule

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

有什么想法吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

你的意思吗?

    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))
        { 
            // ...
        }
    }