如何統計asp.net c#中網站的訪問者數量?如何統計asp.net網站的訪問者數量c#
我使用下面的代碼:
在Global.asax的頁面
<%@ Application Language="C#" %>
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["NoOfVisitors"] = 0;
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Application.Lock();
Application["NoOfVisitors"] = (int)Application["NoOfVisitors"] + 1;
Application.UnLock();
}
在.aspx頁面中
<asp:Label runat="server" ID="lbluser" />
在.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
lbluser.Text = Application["NoOfVisitors"].ToString();
}
應用程序計數器被重置爲0,每隔一小時...... 我在哪裏在計數的用戶數量犯了錯誤? ...謝謝你...
我已經在bigrocks中託管網站....我會將這些信息發送給他們。 – 2014-10-04 04:56:39
這樣應用程序池將在特定時間段後重新啓動? – 2014-10-04 05:06:36