Click here to Skip to main content
16,012,082 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
C#
void Session_Start(object sender, EventArgs e) 
    {
        if (Session.IsNewSession)
        {

            HttpCookie sessionCookie = Request.Cookies["ASP.NET_SessionId"];
            if ((null != sessionCookie) && !string.IsNullOrEmpty(sessionCookie.Value))
            {
                Response.Redirect("login.aspx?ReturnUrl=" + Request.Url.LocalPath);
            }
            else
            {
                return;
            }
            
        }
        else
        {
            if (Session.Count == 0)
            {
                Response.Redirect("login.aspx?ReturnUrl=" + Request.Url.LocalPath);
            }
            else
            {
                return;
            }
            
        }
}

C#
void Session_End(object sender, EventArgs e)
   {
       if (Session.Count==0)
       {
           return;
       }
       else
       {
           Application.Lock();
           Application["UsersOnline"] = (int)Application["UsersOnline"] - 1;
           Application.UnLock();
           Session.Clear();

       }


   }



in this after logout it will redirects a loop .. please help me any one ..

Thanks Advance..
Posted
Updated 14-Aug-12 0:09am
v2

1 solution

you should use session.abondened rather than session.clear.
try it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900