如何计算在asp.net中的服务器应用程序会话 [英] How to count sessions in asp.net server application
本文介绍了如何计算在asp.net中的服务器应用程序会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有是管理一个asp.net运行aplication多少会话有办法?我想如果有展示它在一个页面,可能与其他一些重要的信息。而且,我该怎么办呢?谢谢!
There is a way to manage how many sessions an asp.net running aplication have? I want to exhibit it in a page, maybe with some other important information, if available. And, how can I do it? Thanks!
推荐答案
在的Global.asax
,请执行以下操作:
在处理 Application.Start
事件添加以下内容:
Handle the Application.Start
event adding the following:
Application["LiveSessionsCount"] = 0;
在处理 Session.Start
事件添加以下内容:
Application["LiveSessionsCount"] = ((int) Application["LiveSessionsCount"]) + 1;
在处理 Session.End
事件添加以下内容:
Application["LiveSessionsCount"] = ((int) Application["LiveSessionsCount"]) - 1;
要检索的会话数内您的网页编写如下:
To retrieve sessions count inside your page write the following:
int LiveSessionsCount = (int) Application["LiveSessionsCount"];
这篇关于如何计算在asp.net中的服务器应用程序会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文