如何取得连接到ASP.NET网站的用户数量? 可以在.CS代码里用C#语言取得吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在 Global.apx.cs 文件protected void Session_Start(Object sender, EventArgs e) { Application.Lock(); Application["SessionCount"] = (int)Application["SessionCount"] + 1; Application.UnLock(); } protected void Session_End(Object sender, EventArgs e) { Application.Lock(); Application["SessionCount"] = (int)Application["SessionCount"] - 1; Application.UnLock(); } 计算服务器端所有session的数量 "计算服务器端所有session的数量"能把语句写出来吗? 能不能说的详细点,我没用过Global.aspx这个文件。这2个函数又是怎么触发的呢?非常感谢~ 这两个事件不用你触发,当一个Session开始和结束自然就触发了 Global.aspx<%@ Application Language="C#" %><script runat="server"> void Application_Start(object sender, EventArgs e) { // 在应用程序启动时运行的代码 //SocutKey.Go(); Application["userCount"] = 0; } void Application_End(object sender, EventArgs e) { // 在应用程序关闭时运行的代码 } void Application_Error(object sender, EventArgs e) { // 在出现未处理的错误时运行的代码 } void Session_Start(object sender, EventArgs e) { // 在新会话启动时运行的代码 Application.Lock(); Application["userCount"] = (int)Application["userCount"] + 1; Application.UnLock(); } void Session_End(object sender, EventArgs e) { // 在会话结束时运行的代码。 // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为 // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer // 或 SQLServer,则不会引发该事件。 } </script>在需要统计的页面.cs文件中 Label1.Text = Application["userCount"].ToString();再在需要统计的页面.aspx文件中共有<asp:Label ID="Label1" runat="server"></asp:Label>人在线 高手答疑,分不够再加,再此先谢 无聊提问。问:MySQL5.0存储过程返回值 有关Treeview的权限控制问题 怎么刷新不提交数据 请教一个关于LISTBOX的问题,百分相赠!高手请指教! JMail接收邮件时显示接收状态和取消接收? 请问如何去掉字符串中重复的字符,谢谢了。 一个Visual Studio.Net 2003设置问题! 请问有没有好的测试软件 或 方法 可以用来 测试 C# windows服务的 help!一个有趣的问题...... 这个网站有漏洞吗 请教下面两种方式的优劣性
在 Global.apx.cs 文件
protected void Session_Start(Object sender, EventArgs e)
{
Application.Lock();
Application["SessionCount"] = (int)Application["SessionCount"] + 1;
Application.UnLock();
}
protected void Session_End(Object sender, EventArgs e)
{
Application.Lock();
Application["SessionCount"] = (int)Application["SessionCount"] - 1;
Application.UnLock();
}
void Application_Start(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码
//SocutKey.Go();
Application["userCount"] = 0;
}
void Application_End(object sender, EventArgs e)
{
// 在应用程序关闭时运行的代码 }
void Application_Error(object sender, EventArgs e)
{
// 在出现未处理的错误时运行的代码 } void Session_Start(object sender, EventArgs e)
{
// 在新会话启动时运行的代码
Application.Lock();
Application["userCount"] = (int)Application["userCount"] + 1;
Application.UnLock(); } void Session_End(object sender, EventArgs e)
{
// 在会话结束时运行的代码。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
// InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer
// 或 SQLServer,则不会引发该事件。 }
</script>在需要统计的页面.cs文件中
Label1.Text = Application["userCount"].ToString();再在需要统计的页面.aspx文件中
共有<asp:Label ID="Label1" runat="server"></asp:Label>人在线