Unable to connect to SQL Server Session Database

My asp.net applications work great every day. Until last month, my website begins to receive 2-3 times problems with the Sqlsession status server as follows:

Blockquote System.Web.HttpException An exception of type "System.Web.HttpException" was thrown. on System.Web.HttpAsyncResult.End () in System.Web.SessionState.SessionStateModule.EndAcquireState (IAsyncResult ar) in System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion (IAsync================ ======================================= Exception: System.Web.HttpException Unable to connect to SQL Server Session Database at System.Web.SessionState.SqlSessionStateStore.ThrowSqlConnectionException (SqlConnection conn, Exception e) at System.Web.SessionState.SqlSessionStateStore.SqlStateConnection..ctor (SqlPartitionInfo sqlPartitionInfo usePooling) in System.Web.SessionState.SqlSessionStateStore.DoGet (HttpContext context,row id, boolean getExclusive, boolean and locked, TimeSpan and lock, Object & lockId, SessionStateActions & actionFlags) in System.Web.SessionState.SqlSessionStateStore.GetItemExclusive (HttpContext context, String id, Boolean & locked, TimeSpan & LockAge, Object & lockId , SessionStateActions & actionFlags) in System.Web.SessionState.SessionStateModule.GetSessionStateItem () in System.Web.SessionState.SessionStateModule.PollLockedSessionCallback (object state) === ================= ================================ Exception: system .InvalidOperationException Timed out. The wait period expires before a connection is received from the pool. Perhaps this was due to the fact that all joined connections were used and the maximum pool size was reached. in System.Data.ProviderBase.DbConnectionFactory.GetConnection (DbConnection owningConnection) in System.Data.ProviderBase.DbConnectionClosed.OpenConnection (external DbConnection, DbConnectionFactory connectionFactory) in System.Data.SqlClient.SqlConnection.Open () in System.Web.Session SqlSessionStateStore.SqlStateConnection..ctor (SqlPartitionInfo sqlPartitionInfo)

"EXEC sp_who" SQL , AspState .

, , , .

​​ -:

asp.net 3.5 ( 1.1)... 2 sqlmode .

- - ?

+3
6

, . , :

using (SqlConnection cn = new SqlConnection(connectionString))
{
    using (SqlCommand cm = new SqlCommand(commandString, cn))
    {
        cn.Open();
        cm.ExecuteNonQuery(); // or fill a dataset, etc.
    }
}

"using", .

, .

+3

, , SqldataReaders , , , , CloseConnection. ( ), . , , .

+2

, , , .

- ASP.NET MVC, .NET 4.5.2, . ASPState SQL Server 2012 ( 11.0.5058.0). :

:      : HttpException      : SQL Server. . . , - , .

, , . , .

:

  • 100 web.config:

      sqlConnectionString="data source=SERVERNAME;Initial Catalog=AspState;user id=AspStateUser;password=xxxxx;App=xxxx; Max Pool Size=200;" 
    
  • , AspState .NET 2.0, , , dbo.DeleteExpiredSessions SP . , . AspState .NET 4.0 :

C:\Windows\Microsoft.NET\Framework\v4.0.30319 > aspnet_regsql.exe -ssadd - sstype c -S OURSERVERNAME -d "AspState" -E

DeleteExpiredSessions, , . , .

+2

? , , .

, , - . , , . , , .

+1

, connectionString <configuration> <sessionState>. <configuration>, , SQL-.

<sessionState>, .

+1

All Articles