实现在线用户统计
Global.asax.vb中的代码:
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Application("user_sessions") = 0
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock()
Application("user_sessions") = Application("user_sessions") + 1
Application.UnLock()
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock()
Application("user_sessions") = Application("user_sessions") - 1
Application.UnLock()
End Sub
Aspx中的的代码:
Label1.Text = "本站当前有: <b>" + Application("user_sessions").ToString() + "" + "</b> 位访问者 !"