ببینیدولی این کد تعداد بازدید کننده های فعلی رو هم همواره 1 نشون میده !!!!
من امتحانش کردم ولی درست عمل نمی کنه !!!
برای اینکه بتونم توی دیتا بیس تعداد رو ذخیره کنم باید به جای session به مقدار دیتا بیس یکی اضافه کنم؟
برای جدا کردن اطلاعات هر روز از روز دیگه باید چیکار کنم؟
من سر این کد یه مقدار مشکل دارم میشه بیشتر توضیح بدید
متشکرم
Sub Application_OnStart
application("intactiveusernumber") = 0
End Sub
Sub Session_OnStart
session.timeout = 20
application.lock
application("intactiveusernumber") = application("intactiveusernumber") + 1
Application.UnLock
End Sub
Sub Session_OnEnd
Application.Lock
Application("intActiveUserNumber") = Application("intActiveUserNumber") - 1
Application.UnLock
End Sub
<%
Response.Write Application("intActiveUserNumber")
%>
Imports System.Web
Imports System.Web.SessionState
Public Class Global
Inherits System.Web.HttpApplication
#Region " Component Designer Generated Code "
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Required by the Component Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Component Designer
'It can be modified using the Component Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
#End Region
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
Application("intactiveusernumber") = 0
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session is started
Session.Timeout = 20
Application.Lock()
Application("intactiveusernumber") = Application("intactiveusernumber") + 1
Application.UnLock()
End Sub
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires at the beginning of each request
End Sub
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires upon attempting to authenticate the use
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Fires when an error occurs
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
Application.Lock()
Application("intactiveusernumber") = Application("intactiveusernumber") - 1
Application.UnLock()
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application ends
End Sub
End Class
Label7.text=Application("intActiveUserNumber")
سلام
چطور می تونم تعداد بازدید کننده های امروز رو از طریق ای اس پی کلاسیک مشخص کنم؟
Sub Application_OnStart
'Create an ActiveUsersNumber variable with Application scope and set it to 0
Application("intActiveUserNumber") = 0
End Sub
Sub Session_OnStart
Session.Timeout = 20
'The appilcation must be locked so that only one user can increment the Application ActiveUserNumber variable at a time
Application.Lock
'The Application ActiveUserNumber variable is incremented by 1
Application("intActiveUserNumber") = Application("intActiveUserNumber") + 1
'The application is now unlocked
Application.UnLock
End Sub
Sub Session_OnEnd
'The appilcation must be locked so that only one user can decrement the Application ActiveUserNumber variable at a time
Application.Lock
'The Application ActiveUserNumber variable is decremented by 1
Application("intActiveUserNumber") = Application("intActiveUserNumber") - 1
'The application is now unlocked
Application.UnLock
End Sub
<%
'Alternative to display text output instead
'Response.Write Application("intActiveUserNumber")
%>