viet vo quoc

viet vo quoc

  • NA
  • 115
  • 105.5k

The session_End method didn't work?Why.

Oct 31 2011 10:33 PM
Hj. I make a counter for my website .It's very plain!!.And when i run website on localhost by much browser ,So it's right.But when i turn off a browser and refresh  browser remain .It's not right and i think this is problem from Session_End in global.asax.This is my code .Hope everyone help me about that!

protected void Application_Start(object sender, EventArgs e)
        {
            Application["person_online"] = 0;
        }

        protected void Session_Start(object sender, EventArgs e)
        {
            Application.Lock();          
            Application["person_online"] = Convert.ToInt32(Application["person_online"]) + 1;           
            Application.UnLock();
           
        }
 protected void Session_End(object sender, EventArgs e)
        {
            Application.Lock();
            Application["person_online"] =Convert.ToInt32(Application["person_online"])-1;
            Application.UnLock();
        }


Attachment: test_cookies.rar

Answers (2)