本文介绍了访问该网站的访客数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不进行数据库交互的情况下获取访问该网站的访问者数量
How to get the count of visitors visiting the website,without having database interaction
推荐答案
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["Users"]=0;
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Session["suer"] =Convert.ToInt32( Application["Users"])+ 1;
Application["Users"] = Session["suer"];
}
然后页面加载
then on page load
Response.Write(Session["suer"].ToString());
void Application_OnStart(Object Sender, EventArgs E)
{
Application["CurrentUsers"] = 0;
}
void Session_OnStart(object Sender, EventArgs E)
{
Application.Lock();
Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) + 1;
Application.UnLock();
}
void Session_OnEnd(object Sender, EventArgs E)
{
Application.Lock();
Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) - 1;
Application.UnLock();
}
这篇关于访问该网站的访客数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!