【问题标题】:What's the difference between the timeout property specified in the Web.Config and the ExpiryDate property of the FormsAuthenticationTicket?Web.Config 中指定的 timeout 属性和 FormsAuthenticationTicket 的 ExpiryDate 属性有什么区别?
【发布时间】:2010-07-03 14:24:54
【问题描述】:

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

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

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

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

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

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2016-04-29
      • 2011-11-14
      • 1970-01-01
      • 1970-01-01
      • 2010-09-20
      相关资源
      最近更新 更多