Form验证,怎么实现页面无操作一段时候后才过期 我用的是Form登录,我想在有请求时如果cookie 的过期时间小于10min重新更改cookie的过期时间。但是cookie的过期时间无法获取!怎么实现页面无操作一段时候后才过期。。Form验证cookie 的过期时间页面过期 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 将过期时间存为cookie value一部分 问题是貌似cookie的过期时间无法更改。。 cookie的过期时间设置为固定值,每次请求时renew cookie的过期时间,以上。 我已经这样做了,还是不行,也许和Form验证登录有关。FormsAuthenticationTicket 验证票过期。。 没源码 没真相 这是登录成功后发放的验证票,过期时间为20min://验证票 //System.Web.Security.FormsAuthentication.SetAuthCookie(this.tbLoginName.Text,true); //Create ticket FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, tbLoginName.Text, DateTime.Now, DateTime.Now.AddMinutes(20), true, ""); //Encrypt the ticket. String encTicket = FormsAuthentication.Encrypt(ticket); //Create the cookie. Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));这是每次请求时执行TimeSpan ts = System.Web.HttpContext.Current.Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName].Expires - DateTime.Now; if (ts.TotalMinutes < 10) { System.Web.HttpContext.Current.Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMinutes(20); System.Web.HttpContext.Current.Request.Cookies["loginInfo"].Expires=DateTime.Now.AddMinutes(20); }结果是不管有页面没有请求到20min就过期了。。 结果是不管页面有没有请求到20min就过期了 单是修改过期时间没用的,要重新"添加"到Response里... 哈哈!问题自己解决了!!在Web.config 的forms标签中加入 slidingExpiration="true" 就行了 ,不用再手动修改coockie的过期时间了!! 怎么把系统抽象化? 错误: 属性“WebForm_AutoFocus”的值为 null、未定义或不是 Function 对象 请教ASP.NET使用FTP上传大文件 有没有办法,在页面加载完后就立即断开与服务器的连接? VS2005与VS2008进行压力测试 在ASP.NET中采用框架技术用什么方法才能在TOP框架中控制打开MAIN中的页面 谁能帮我找个软件(分数不够还可以加):) 求OA中个人办公中的---个人文件柜模块代码 请问将jmail转换成.net组件的问题 大量数据分页,根据任意字段排序问题。 如何控制网页的前进后退? .net Excel导入问题
这是登录成功后发放的验证票,过期时间为20min://验证票
//System.Web.Security.FormsAuthentication.SetAuthCookie(this.tbLoginName.Text,true);
//Create ticket
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, tbLoginName.Text, DateTime.Now, DateTime.Now.AddMinutes(20), true, "");
//Encrypt the ticket.
String encTicket = FormsAuthentication.Encrypt(ticket);
//Create the cookie.
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
这是每次请求时执行TimeSpan ts = System.Web.HttpContext.Current.Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName].Expires - DateTime.Now;
if (ts.TotalMinutes < 10)
{
System.Web.HttpContext.Current.Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddMinutes(20);
System.Web.HttpContext.Current.Request.Cookies["loginInfo"].Expires=DateTime.Now.AddMinutes(20);
}
结果是不管有页面没有请求到20min就过期了。。