Counting online users using asp.net

前端 未结 4 1955
星月不相逢
星月不相逢 2020-12-11 20:22

I\'m to create a website for which I need to count the online users and show it on the home page all the time. I\'m not interested to apply ready-to-use modules for it. Here

4条回答
  •  生来不讨喜
    2020-12-11 20:48

    You could use onUserExit jQuery plugin to call some server side code and abandon the session. Activate onUserExit on document ready :

    
    

    And in EndSession.ashx abandon the session and server side Session_End will be called :

    public void ProcessRequest(HttpContext context)
    {
      context.Session.Abandon();
      context.Response.ContentType = "text/plain";
      context.Response.Write("My session abandoned !");
    }
    

    note that this will not cover all cases (for example if user kills browser trough task manager).

提交回复
热议问题