网站访问量突然从二千多变到四百多,不知啥原因,请大家帮忙看看程序~~~
刚刚客户来电话,说网站的访问量统计的数字,突然从二千多,变到了四百多...
我检查了程序没问题呀,不知咋回事了,下面是Global里的源代码,大家帮看分析下:
void Application_Start(object sender, EventArgs e)
{
System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("~/网站访问量统计.txt"), System.IO.FileMode.Create);
System.IO.StreamReader sr = new System.IO.StreamReader(fs);
if (Convert.ToInt32(Application["AllUser"]) != 0)
{
Application["AllUser"] = Convert.ToInt32(sr.ReadLine());
}
else
{
Application["AllUser"] = 1;
}
sr.Close();
fs.Close();
}
void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application["AllUser"] = Convert.ToInt32(Application["AllUser"]) + 1;
System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("~/网站访问量统计.txt"), System.IO.FileMode.Open);
System.IO.StreamWriter sw = new System.IO.StreamWriter(fs, Encoding.UTF8);
sw.Write(Convert.ToInt32(Application["AllUser"]));
sw.Close();
fs.Close();
Application.UnLock();
}