.net 中怎样实现在线人数的统计和在线会员的信息显示 .net 中怎样实现在线人数的统计和在线会员的信息显示(就是把所有的会员的id,IP显示)!!求高人解决!!万分感谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在Global.ascx中做,这样是最简单的,但是统计太粗糙.如果想要精细的统计,得用别的办法了.protected void Application_Start(Object sender, EventArgs e) { try { long lCount = 0; StreamReader sdr = new StreamReader(Server.MapPath("App_Data/count.txt")); string strCount = sdr.ReadLine(); if (strCount != null) { if (strCount.Trim().Replace(((char)13).ToString(), "") != "") { lCount = long.Parse(strCount); } } sdr.Close(); Application.Lock(); Application["counter"] = lCount; Application.UnLock(); } catch { } } protected void Session_Start(Object sender, EventArgs e) { try { if (Request.ServerVariables["URL"].IndexOf("admin") == -1) { long lCount = 0; lCount = long.Parse(Application["counter"].ToString()) + 1; StreamWriter sw = new StreamWriter(Server.MapPath("App_Data/count.txt")); sw.Write(lCount.ToString()); sw.Close(); Application.Lock(); Application["counter"] = lCount; Application.UnLock(); } } catch { } }至于在线人数,在session_start里加入session判断就行了.有session的为登陆,没有的别为游客. 今天面试的一道题 如何用C#实现禁用和启用网卡 一个小白问题 C#国际化问题--急 double db = 3.03-3; Listview中光标的问题 请问简单高效的方法获取ACCESS字段的长度? 关于SQLDMO的菜鸟问题[无法列出本地网络中可使用的SQL服务器列表] [问题分享]VS2013自带的Newtonsoft导致的编译异常 Tlbimp这个工具的问题, 敬请赐教!!! 请教SeraiPort 运行一段时间后就不接收数据了是怎么回事呢 TCP的客户端........(急急)
{
try
{
long lCount = 0;
StreamReader sdr = new StreamReader(Server.MapPath("App_Data/count.txt"));
string strCount = sdr.ReadLine();
if (strCount != null)
{
if (strCount.Trim().Replace(((char)13).ToString(), "") != "")
{
lCount = long.Parse(strCount);
}
}
sdr.Close();
Application.Lock();
Application["counter"] = lCount;
Application.UnLock();
}
catch { }
}
protected void Session_Start(Object sender, EventArgs e)
{
try
{
if (Request.ServerVariables["URL"].IndexOf("admin") == -1)
{
long lCount = 0;
lCount = long.Parse(Application["counter"].ToString()) + 1;
StreamWriter sw = new StreamWriter(Server.MapPath("App_Data/count.txt"));
sw.Write(lCount.ToString());
sw.Close();
Application.Lock();
Application["counter"] = lCount;
Application.UnLock();
}
}
catch { }
}至于在线人数,在session_start里加入session判断就行了.有session的为登陆,没有的别为游客.