开发者

why the session to sql server is out at this case?

开发者 https://www.devze.com 2022-12-08 21:12 出处:网络
I used linq to entites to connect to database, and recently i found the following problem, when i open the website and login, and and I leave the page idle for around 10 minutes, the click the link in

I used linq to entites to connect to database, and recently i found the following problem, when i open the website and login, and and I leave the page idle for around 10 minutes, the click the link in the website which make a connection to database. But it seems that the connect to sql server 2005 is out, and it will automatically reconnect to database. and in the process, it will throw out the following exception:

 System.Data.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParserStateObject.WriteSni()
       at System.Data.SqlClient.TdsParserStateObject.WritePacket(Byte flushMode)
       at System.Data.SqlClient.TdsParserStateObject.ExecuteFlush()
       at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Bool开发者_Python百科ean async)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
       --- End of inner exception stack trace ---
       at System.Data.EntityC

Is there any solution for this problem ? After every connection, does the linq automatically close the connection or not ? How to set or config this ?


Couple of suggestions... is there anything stored in the Session that affects the connection? You can increase the Session timeout in the web.config...

<system.web> 
    <sessionState timeout="20" />
<system.web> 

Finally - I've seen the A transport-level error has occurred... error occur on networks that drop connections... any issues there?

0

精彩评论

暂无评论...
验证码 换一张
取 消