My interested stuff(2008-08-03)

SQL

 Excel

Add-in

Web

Other

 

How do I detect a session has expired and redirect it to another page

override protected void OnInit(EventArgs e)
  {
       base.OnInit(e);
if (Context.Session != null)
   {    if (Session.IsNewSession)
    {
    string szCookieHeader = Request.Headers["Cookie"];
     if ((null != szCookieHeader) && (szCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
     {
      Response.Redirect("sessionTimeout.htm");
     } 
    }
   }
  }

posted @ 2008-08-02 01:12  代码乱了  阅读(527)  评论(0编辑  收藏  举报