Asp.net 查看当前联机用户的代码未给出正确的输出

Asp.net 查看当前联机用户的代码未给出正确的输出,asp.net,Asp.net,我已经编写了一个代码来查看asp.net(vb)中的在线用户,但是当页面运行时,它不会显示正确的输出,它只显示3个在线用户,如果打开更多页面,那么它也会显示相同的用户。我已将代码粘贴到下面。请帮助我 Public Class Global_asax Inherits System.Web.HttpApplication Dim i As Integer Sub Application_Start(ByVal sender As Object, ByVal e As Eve

我已经编写了一个代码来查看asp.net(vb)中的在线用户,但是当页面运行时,它不会显示正确的输出,它只显示3个在线用户,如果打开更多页面,那么它也会显示相同的用户。我已将代码粘贴到下面。请帮助我

Public Class Global_asax
    Inherits System.Web.HttpApplication
    Dim i As Integer
    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the application is started
        Application("hitcount") = 0
    End Sub

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the session is started
        i = Application("hitcount")
        Application.Lock()

        i = i + 1
        Application("hitcount") = Application("hitcount") + 1
        Application.UnLock()

    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the session ends
        Application.Lock()
        If Application("hitcount") > 0 Then
            Application("hitcount") = Application("hitcount") - 1
            Application.UnLock()
        End If
    End Sub

    Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the application ends
        'Application.UnLock()

    End Sub

End Class
这不应该是:

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) 
    ' Fires when the session ends 
    Application.Lock() 
    If Application("hitcount") > 0 Then 
        Application("hitcount") = Application("hitcount") - 1 
    End If 
    Application.UnLock()   ' <------
End Sub 
子会话\u结束(ByVal发送方作为对象,ByVal e作为事件参数)
'在会话结束时激发
Application.Lock()
如果应用程序(“命中次数”)大于0,则
应用程序(“命中数”)=应用程序(“命中数”)-1
如果结束
Application.UnLock()