在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);
为什么我可以在两个地方设置有关表单身份验证的过期信息?他们之间有什么区别?什么更有意义?
答案 0 :(得分:2)
web.config中的超时是会话级别的提示。例如。如果用户处于非活动状态30分钟(默认),则系统将提示他或她再次登录。
如果您使用“记住我”功能,FormsAuthenticationTicket中的expiryDate是Cookie的失效日期。