我正在生成一个 FormsAuthentication 票证,并将其存储在一个 cookie 中,我将其与 MVC AuthorizeAttribute 一起使用以提供授权。现在,我得到了它,所以如果我选中了“保持登录”复选框,cookie 就不会过期,(我只是将 cookie.expires 更改为 now + 1 年,用于测试目的,当他们'已检查以保持登录状态)。
但是,即使我在创建票证时设置了 cookie 是持久的,但票证在超时期限后仍然停止工作。
这是我创建 AuthTicket 的代码:
var now = DateTime.UtcNow.ToLocalTime();
FormsAuthenticationTicket authTicket = new System.Web.Security.FormsAuthenticationTicket(1, username, now, now.Add(FormsAuthentication.Timeout), rememberMe, username, FormsAuthentication.FormsCookiePath);
string encryptedTicket = System.Web.Security.FormsAuthentication.Encrypt(authTicket);
return encryptedTicket;
这与我设置为 cookie 的 encryptedTicket 相同。任何人都知道我怎样才能让这张票超过 FormsAuthentication 超时?我只需要手动弄乱 FormsAuthentication Timeout 时间吗?