Blog Reader RSS LoveCherry 技术无极限 GEO MVP MS Project开源技术

session相关问题

在asp.net中,如何使得当session过期后自动跳转到登陆页呢?下面我提供一个简单的方法:
 private void Page_Load(object sender, System.EventArgs e)

{

      Response.AddHeader("Refresh",Convert.ToString((Session.Timeout * 60) + 5));

      if(Session[“IsUserValid”].ToString()==””)

            Server.Transfer(“Relogin.aspx”);

}
在page.load事件中,加入response.addheader方法,当session过期失效后的5秒,页面就会自动刷新,这
个时候,判断到session失效了,之后系统自动跳转了

如何使得关闭页面立即结束会话session
Session_OnEnd()   will   not   be   called   if   the   user   just   closed   his   window   and   will   be   called   when   the   Session   times   out  
   
  1.   in   your   page   (not   always   work,   for   example,   when   the   user   browser   away   from   your   site)  
  <script   language="javascript">  
  function   window.onunload()  
  {  
      if   (event.clientX   <   0   &&   event.clientY   <   0)  
          window.open("logout.aspx","logout");  
  }  
  </script>   
in   logout.aspx,   call  
  <%  
  Session.Abandon()  
  %>  
   
  2.   use   a   method   which   doesn't   use   Session_OnStart/Session_OnEnd,   for   example,   keep   a   DataTable   in   an   Application   variable   and   record     users'   last   access   time,   the   DataTable   is   checked   every   time   a   user   sends   a   request,   if   the   access   time   for   any   user   was   10   minutes   ago,   you   remove   the   user   from   the   DataTable  
但是我发现这种关闭页面即关闭SESSION的方法很不实际.

posted @ 2008-04-10 14:05 大宋提刑官 阅读(51) 评论(0)  编辑 收藏 网摘

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2008-04-11 21:40 编辑过
Google站内搜索
[推荐职位]上海盛大网络招聘架构师



China-pub 计算机图书网上专卖店!6.5万品种 2-8折!
近千种 9-95 新二手计算图书火热销售中!
开发者征途系统新作:《设计模式——基于C#的工程化实现及扩展》

相关文章:


相关搜索:
一品梅的小本本

相关链接: