Web.Config中指定的超时属性与FormsAuthenticationTicket的ExpiryDate属性之间有什么区别?

时间:2010-07-03 14:24:55

标签: c# .net asp.net authentication forms-authentication

在Web.Config中,我们有一个超时属性。例如:

<authentication mode="Forms">
      <forms loginUrl="~/Login.aspx" timeout="2880"/>
    </authentication>

当登录时,我们可以指定票证到期日期。例如:

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                     1, id.ToString(), DateTime.Now, expiryDate, true,
                     securityToken, FormsAuthentication.FormsCookiePath);

为什么我可以在两个地方设置有关表单身份验证的过期信息?他们之间有什么区别?什么更有意义?

1 个答案:

答案 0 :(得分:2)

web.config中的超时是会话级别的提示。例如。如果用户处于非活动状态30分钟(默认),则系统将提示他或她再次登录。

如果您使用“记住我”功能,FormsAuthenticationTicket中的expiryDate是Cookie的失效日期。

相关问题