代码之家  ›  专栏  ›  技术社区  ›  Andre Pena

web.config中指定的timeout属性和formsAuthenticationTicket的expiryDate属性有什么区别?

  •  0
  • Andre Pena  · 技术社区  · 15 年前

    在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 回复  |  直到 15 年前
        1
  •  2
  •   Mart    15 年前

    web.config中的超时为会话级别timout。如果用户处于非活动状态30分钟(默认),则会提示他或她重新登录。

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

    推荐文章