2013-02-15 72 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);是电话