2012-01-05 29 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