博客中统计多少人看过我的页面问题 博客中,怎样统计多少人看过我的页面,统计多少人看过我的文章。高手帮忙啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Global.asax里的代码当服务器关闭时不能保存人数,因此用一个记事本来记录在工程目录下新建一个count.txt文件保存人数统计 protected void Application_Start(object sender, EventArgs e) { uint count = 0; StreamReader srd; //取得文件的实际路径 string file_path = Server.MapPath("count.txt"); //打开文件进行读取 srd = File.OpenText(file_path); while (srd.Peek() != -1) { string str = srd.ReadLine(); count = UInt32.Parse(str); } object obj = count; Application["count"] = obj; srd.Close(); } protected void Session_Start(object sender, EventArgs e) { Application.Lock(); //数值累加 uint jishu = 0; jishu = (uint)Application["count"]; jishu = jishu + 1; object obj = jishu; Application["count"] = obj; //将数据记录写入文件 string file_path = Server.MapPath("count.txt"); StreamWriter fs = new StreamWriter(file_path, false); fs.WriteLine(jishu); fs.Close(); Application.UnLock(); } protected void Application_BeginRequest(object sender, EventArgs e) { } protected void Application_AuthenticateRequest(object sender, EventArgs e) { } protected void Application_Error(object sender, EventArgs e) { } protected void Session_End(object sender, EventArgs e) { } protected void Application_End(object sender, EventArgs e) { //装箱 uint js = 0; js = (uint)Application["count"]; //object obj=js; //Application["counter"]=js; //将数据记录写入文件 string file_path = Server.MapPath("count.txt"); StreamWriter fs = new StreamWriter(file_path, false); fs.WriteLine(js); fs.Close(); } 谢谢wuzexing的帮忙,我的用户登录部分是用MemberShip做的,统计时可以用以上代码吗 数据控件嵌套中,如何获取子数据控件里的控件 VS2012创建ASP.NET WEB窗体应用程序失败?请各位大大帮帮忙,找了一下午没找到解决方法 .net如何根据年月算出这个月有几个周,分别是几号到几号 怎么样能使数据库文件变小 DateTime.Now得到的日期,为什么不能写到SQL SERVER数据库datetime数据类型的字段里? [弟兄们急]关于日历的问题 asp.net的基础一问! 新手;中文显示的问题。 哪位大哥有架设IIS6.0的经验??200分求助 急!!!怎样在DataGrid中显示图片? 时间显示的问题.上次未解决.这次接着问 如何删除URL中括号里自动生成的代码?
当服务器关闭时不能保存人数,因此用一个记事本来记录
在工程目录下新建一个count.txt文件保存人数统计 protected void Application_Start(object sender, EventArgs e)
{
uint count = 0;
StreamReader srd;
//取得文件的实际路径
string file_path = Server.MapPath("count.txt");
//打开文件进行读取
srd = File.OpenText(file_path);
while (srd.Peek() != -1)
{
string str = srd.ReadLine();
count = UInt32.Parse(str);
}
object obj = count;
Application["count"] = obj;
srd.Close(); } protected void Session_Start(object sender, EventArgs e)
{
Application.Lock();
//数值累加
uint jishu = 0;
jishu = (uint)Application["count"];
jishu = jishu + 1;
object obj = jishu;
Application["count"] = obj;
//将数据记录写入文件
string file_path = Server.MapPath("count.txt");
StreamWriter fs = new StreamWriter(file_path, false);
fs.WriteLine(jishu);
fs.Close();
Application.UnLock();
} protected void Application_BeginRequest(object sender, EventArgs e)
{ } protected void Application_AuthenticateRequest(object sender, EventArgs e)
{ } protected void Application_Error(object sender, EventArgs e)
{ } protected void Session_End(object sender, EventArgs e)
{ } protected void Application_End(object sender, EventArgs e)
{
//装箱
uint js = 0;
js = (uint)Application["count"];
//object obj=js;
//Application["counter"]=js;
//将数据记录写入文件
string file_path = Server.MapPath("count.txt");
StreamWriter fs = new StreamWriter(file_path, false);
fs.WriteLine(js);
fs.Close(); }