本文介绍了在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
推荐答案
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中计数(当前在线用户)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!