EDN Admin
Well-known member
Recently we upgraded our web applications to .Net framework 4.0 from 3.5. Of late we are finding that some users are able to see other users session data. When they login with their credentials, they see other users session data. We use
ASP Membership & Role providers for authentication/authorization; store session in ASP State database; forms authentication; web farm environment.
We did not have this problem until we upgraded to .net 4.0. From our error log files we were able to see that the connection to ASP State database was failing saying that it had reached the max pool size. Below is a sample error message
[IsAuthenticated: - True] [Stack: - System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool
size was reached.<br/>
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)<br/>
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)<br/>
at System.Data.SqlClient.SqlConnection.Open()<br/>
at System.Web.SessionState.SqlSessionStateStore.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo, TimeSpan retryInterval)]
Do you think increasing the Max Pool Size will resolve this issue? We now have it at 150. Below is a sample from our custom session object creation & retrieval. Please let us know how to resolve this issue? Your inputs are greatly appreciated.
Thanks,
Vinny
<pre class="prettyprint lang-vb Public Class StudentDataSessionFactory
Public Function createInstance(ByVal username As String, ByVal studentId As String, ByVal companyNo As String, ByVal userRoles As String()) As StudentDataSession
Dim studData As New StudentDataSession(username, studentId, companyNo, userRoles)
Return studData
End Function
End Class[/code]
<pre class="prettyprint lang-vb Public Class StudentDataSessionManager
Public Shared SessionStudentDataKey As String = "XXX_SessionStudentData"
Shared studentDataFactory As New StudentDataSessionFactory
setting up of session object with custom data
Public Shared Sub SetStudentData(ByVal session As HttpSessionState, ByVal studentData As StudentDataSession)
session.Add(SessionStudentDataKey, studentData)
End Sub
Retrieving the customized session object for the current session
Public Shared Function GetStudentData(ByVal session As HttpSessionState) As StudentDataSession
Return CType(session.Item(SessionStudentDataKey), StudentDataSession)
End Function
Initializing customized session object
Public Shared Function InitUserData(ByVal session As HttpSessionState, ByVal username As String, ByVal studId As String, ByVal compId As String, ByVal userRoles As String()) As StudentDataSession
Dim studentData As StudentDataSession = GetStudentData(session)
If studentData Is Nothing Then
studentData = studentDataFactory.createInstance(username, studId, compId, userRoles)
SetStudentData(session, studentData)
studentData = RefreshUserData(session)
End If
Return studentData
End Function[/code]
<br/>
<br/>
View the full article
ASP Membership & Role providers for authentication/authorization; store session in ASP State database; forms authentication; web farm environment.
We did not have this problem until we upgraded to .net 4.0. From our error log files we were able to see that the connection to ASP State database was failing saying that it had reached the max pool size. Below is a sample error message
[IsAuthenticated: - True] [Stack: - System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool
size was reached.<br/>
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)<br/>
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)<br/>
at System.Data.SqlClient.SqlConnection.Open()<br/>
at System.Web.SessionState.SqlSessionStateStore.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo, TimeSpan retryInterval)]
Do you think increasing the Max Pool Size will resolve this issue? We now have it at 150. Below is a sample from our custom session object creation & retrieval. Please let us know how to resolve this issue? Your inputs are greatly appreciated.
Thanks,
Vinny
<pre class="prettyprint lang-vb Public Class StudentDataSessionFactory
Public Function createInstance(ByVal username As String, ByVal studentId As String, ByVal companyNo As String, ByVal userRoles As String()) As StudentDataSession
Dim studData As New StudentDataSession(username, studentId, companyNo, userRoles)
Return studData
End Function
End Class[/code]
<pre class="prettyprint lang-vb Public Class StudentDataSessionManager
Public Shared SessionStudentDataKey As String = "XXX_SessionStudentData"
Shared studentDataFactory As New StudentDataSessionFactory
setting up of session object with custom data
Public Shared Sub SetStudentData(ByVal session As HttpSessionState, ByVal studentData As StudentDataSession)
session.Add(SessionStudentDataKey, studentData)
End Sub
Retrieving the customized session object for the current session
Public Shared Function GetStudentData(ByVal session As HttpSessionState) As StudentDataSession
Return CType(session.Item(SessionStudentDataKey), StudentDataSession)
End Function
Initializing customized session object
Public Shared Function InitUserData(ByVal session As HttpSessionState, ByVal username As String, ByVal studId As String, ByVal compId As String, ByVal userRoles As String()) As StudentDataSession
Dim studentData As StudentDataSession = GetStudentData(session)
If studentData Is Nothing Then
studentData = studentDataFactory.createInstance(username, studId, compId, userRoles)
SetStudentData(session, studentData)
studentData = RefreshUserData(session)
End If
Return studentData
End Function[/code]
<br/>
<br/>
View the full article