2013-02-15 69 views
0

我正試圖在asp.net項目上記住我的系統。我做了用戶註冊並登錄FormsAuthenticationTicket。我想要的是當用戶登錄時,我按預期設置了一個持久性cookie,我驗證了我可以添加該cookie,但FormsAuthenticationTicket不處理記住的事情。這裏是我的代碼asp.net使用FormsAuthenticationTicket記住我係統

ticket = new FormsAuthenticationTicket(1, 
              (String)(drUserInfo["Email"]), 
              DateTime.Now, 
              DateTime.Now.AddMinutes(30), 
              Login1.RememberMeSet, 
              (String)(drUserInfo["UserType"])); 
       encryptedStr = FormsAuthentication.Encrypt(ticket); 

你能幫助我嗎? FormsAuthenticationTicket處理記住我係統還是我?

+0

FormsAuthentication處理它。在asp:Login控件中有一個複選框,用於設置加密的Cookie – 2013-02-15 16:35:42

+0

您可能想要使用ILSpy並檢查asp中發生了什麼:登錄控制代碼 – 2013-02-15 16:36:12

+0

我看到有一個通過登錄控制創建的加密cookie。但仍然沒有工作 – 2013-02-15 16:39:47

回答

0

通過爲ASP源代碼展望:登錄我看到cookie被reated通過以下調用:

呼叫從System.Web.UI.WebControls.Login.AttemptLogin

if (authenticateEventArgs.Authenticated) 
{ 
    FormsAuthentication.SetAuthCookie(this.UserNameInternal, this.RememberMeSet); 
    this.OnLoggedIn(EventArgs.Empty); 
    this.Page.Response.Redirect(this.GetRedirectUrl(), false); 
    return; 
} 

FormsAuthentication.SetAuthCookie(this.UserNameInternal, this.RememberMeSet);是電話