我有一个奇怪的问题,我不知道如何解决。
每次我在应用程序中打开页面时,sessionID 都会不断变化。但是当我调试程序时,sessionID 保持不变并且不会改变
该应用程序安装在 Windows server 2008 R2(iis 7.5 和 dotnet framework 4.0)上
<sessionState cookieless="UseCookies" mode="InProc" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" stateConnectionString="tcpip=127.0.0.1:42424" timeout="60" />
有什么事?
注意:这在我的本地开发机器上运行良好。
编辑
这是 Global.asax.vb 中 Session_Start 的代码
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Session("mySessions") = "junk"
AddMySessions()
If User.Identity.IsAuthenticated Then
Dim cmd As New SqlCommand
Dim sql As String
sql = String.Format("SELECT EmpID FROM Intranet_Employees WHERE Username='{0}'", sUserName)
cmd.CommandText = sql
' Production ...
Session("EmpID") = CType(Dao.ExecuteScalar(cmd, ConfigurationSettings.AppSettings("cSqlTemplateDB")), String)
Dim oEmpInfo As New TOrders.Data.Objects.Employee(Convert.ToInt64(Session("EmpID")))
Session("EmpInfo") = oEmpInfo
If Application("SessionCount") Is Nothing Then
Application.Lock()
Application("SessionCount") = 0
Application.UnLock()
End If
Application.Lock()
Application("SessionCount") += 1
Application.UnLock()
Else
Response.Redirect("http://intranet/tsystem")
End If
End Sub
Private Sub AddMySessions()
Dim sMsg As String = Session.SessionID & ";" & Now.ToString & ";" & Request.ServerVariables.Get("AUTH_USER").ToString
If IsNothing(Application("mySessions")) Then
Dim arrSessions As New ArrayList
arrSessions.Add(sMsg)
Application.UnLock()
Application("mySessions") = arrSessions
Application.Lock()
arrSessions = Nothing
Else
Dim arrTemp As ArrayList = CType(Application("mySessions"), ArrayList)
arrTemp.Add(sMsg)
Application.UnLock()
Application("mySessions") = arrTemp
Application.Lock()
arrTemp = Nothing
End If
sMsg = Nothing
End Sub
`