在web.config中: <authentication mode="Forms">
<forms loginUrl="~/Admin/Login.aspx" defaultUrl="~/Admin/Default.aspx" timeout="30"/>
</authentication>生成票据:FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
2, // 票据版本号
username, // 票据持有者
DateTime.Now, //分配票据的时间
dt, // 失效时间
false, // 是否持久
roles, //角色
FormsAuthentication.FormsCookiePath);//cookie有效路径
现在请问生成票据里的dt我想在web.config的authentication获取timeout的的值后AddMinutes(value).比如现在timeout="30",那么dt=DateTime.Now.AddMinutes(30)就会得到30分钟后失效.现在想问如何获取authentication中的timeout的值?谢谢!
<forms loginUrl="~/Admin/Login.aspx" defaultUrl="~/Admin/Default.aspx" timeout="30"/>
</authentication>生成票据:FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
2, // 票据版本号
username, // 票据持有者
DateTime.Now, //分配票据的时间
dt, // 失效时间
false, // 是否持久
roles, //角色
FormsAuthentication.FormsCookiePath);//cookie有效路径
现在请问生成票据里的dt我想在web.config的authentication获取timeout的的值后AddMinutes(value).比如现在timeout="30",那么dt=DateTime.Now.AddMinutes(30)就会得到30分钟后失效.现在想问如何获取authentication中的timeout的值?谢谢!
System.Web.Configuration.AuthenticationSection section = (System.Web.Configuration.AuthenticationSection)conn.SectionGroups.Get("system.web").Sections.Get("authentication");
long cookieExpires = System.Convert.ToInt64(section.Forms.Timeout.TotalMinutes);
Response.Write(cookieExpires);
但这个值不一定是有效的值