Session过期处理



1、Session失效后,无法跳转到登录页
  能判断出Session=null,并执行了Respose.Write,但不会提示也不跳转
  处理方法:
  1)在总页面index.aspx的page_load中加入
   Response.AddHeader("Refresh",Convert.ToString((Session.Timeout * 60) + 5));
   if(Session[“user_Usrid”]==null) Server.Transfer(“../login.aspx”);   --不完善:跳转后,显示不了登录页的图片,下载文档所在的文件夹也不对了
  2)在总页面index.aspx的page_load中加入
   Response.AddHeader("Refresh",Convert.ToString((Session.Timeout * 60) + 5));
   if(Session[“user_Usrid”]==null) Response.Redirect("../login.aspx");  ---OK

2、Session周期设置
 1)web.config设置:Session timeout默认20分钟,改为300分钟(5小时)

猜你喜欢

转载自blog.csdn.net/af_fire/article/details/79439681