在aspx.cs中计数(当前在线用户) [英] count(currently online user) in aspx.cs

查看:97
本文介绍了在aspx.cs中计数(当前在线用户)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目标题是高峰负载管理,因为我想统计查看该页面的用户数,例如如果超过10位成员,则可以查看该页面,并显示msg(一段时间后请尝试).

预先谢谢你
Ashok kumar

My project title was peak load management, in that I want to count the number of users that view the page, e.g. 10 members can view the page if more than 10, display msg (try after some time).

Thank you in advance
Ashok kumar

推荐答案

global.asax 文件中编写与整个应用程序交互的代码.
示例代码如下:

Write code in global.asax file which interacts with the entire application.
The sample code is given below:

void Application_OnStart(Object Sender, EventArgs E)
        {
            Application["CurrentUsers"] = 0;
        }
        void Session_OnStart(object Sender, EventArgs E)
        {
            Application.Lock();
            Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) + 1;
            Application.UnLock();
        }
        void Session_OnEnd(object Sender, EventArgs E)
        {
            Application.Lock();
            Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) - 1;
            Application.UnLock();
        }



以后您可以尝试解决该问题.



Hereafter you can try it for your issue.


这篇关于在aspx.cs中计数(当前在线用户)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆