2012-01-05 26 views
-1

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

任何想法?

在此先感谢

+0

您的问题太模糊,无法提供有意义的答案。请添加详细信息,示例代码,您尝试过的内容等。 – RickNZ 2012-01-05 06:43:35

回答

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

谢谢Scott。我会测试这个代码,我会更新这个thead。 – 2012-01-05 20:14:06

+0

你好斯科特,我需要知道IsLoginPage和IsLogoutPage。在某些方面,我可以通过IsNewSession知道登录过程,但是,如果我使用表单身份验证,则没有会话。 – 2012-01-05 20:25:27

+0

对不起,我不知道你想要什么..如果你想获得在线用户,可以使用global.asa,并使用session_start和session_end – shenhengbin 2012-01-06 00:46:04