语言c# 访问量计数器 根目录下使用count.dat文件存放网站访问的总人数和在线人数
global.asa怎么写
页面上怎样显示(您是第 位访问者 在线人数 位)
最好给我个全的源代码,谢谢各位大大!!!!!
global.asa怎么写
页面上怎样显示(您是第 位访问者 在线人数 位)
最好给我个全的源代码,谢谢各位大大!!!!!
解决方案 »
- 大家好,我问个梅花雪树控件的问题
- 用Uploadify控件 如何获取上载图片的高宽
- jQuery jstree和Ext的Tree.TreePanel
- 请教:怎样给在自定义类中动态添加的按钮控件响应事件函数??
- 大哥求救,如何通过服务器脚本或Js清空Fckeditor中的内容啊?
- 论坛结帖问题
- 急...!在ASP.NET中加入javascript代码的问题?
- 请问象豆瓣那样的系统算什么系统呢,留言板还是新闻啊,有没有类似的源码
- 如何修改 ListItem item = DropDownList1.Items.FindByValue(selItem);
- 下面是我的代码,为什么编译后不能显示datagrid呢/
- 紧急求助一个超郁闷的题目
- javascript操作XML
要用到application_begain和session_begin方法
protected void Session_Start(Object sender, EventArgs e) +1
protected void Session_End(Object sender, EventArgs e) -1
protected void Application_Start(object sender, EventArgs e)
{
Application["count_user"] = 0;
}
然后用户访问创建session时+1 session失效时-1
protected void Session_Start(object sender, EventArgs e)
{
Application["count_user"] = Convert.ToInt32(Application["count_user"]) + 1;
}
protected void Session_End(object sender, EventArgs e)
{
Application["count_user"] = Convert.ToInt32(Application["count_user"]) - 1;
}
protected void Application_EndRequest(object sender, EventArgs e)
{
if (iprecordPath == string.Empty)
{
iprecordPath = Server.MapPath(".") + "/IPRecord.txt";
}
if (Request.Cookies[""] == null)
{
HttpCookie = new HttpCookie("");
.Value = "1";
Response.SetCookie();
//记录IP
try
{
string IPRecord = Server.MapPath(".") + "/IPRecord.txt";
string Record = string.Format("IP:{0} DateTime:{1} \r\n", Request.UserHostAddress, System.DateTime.Now);
FileStream fs = File.Open(IPRecord, FileMode.Append, FileAccess.Write, FileShare.None);
byte[] buff = System.Text.Encoding.Default.GetBytes(Record);
fs.Write(buff, 0, buff.Length);
fs.Close();
}
catch
{
//无处理
}
}
}
下面两个msdn里的课程里,可能是第一个,也可能是第二个,里有计数器的源代码,还有教程,你试试看。
http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032328332&EventCategory=3&culture=zh-CN&CountryCode=CN
http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032328088&EventCategory=3&culture=zh-CN&CountryCode=CN