Asp. NET timeout time resolved-

Source: Internet
Author: User
Tags connection pooling odbc time limit

Solutions
1. Inside the code, turn off the connection that is not closed
2. Expand the sharing pool by the following methods:
The workaround can be to modify the connection lifetime of the connection pool because the default value is 60 seconds, which is the time that the connection can be saved in the pool after it has been freed from the application.
The specific steps are as follows:
If it is ODBC, you can manually change it in the ODBC Data Source Administrator, which is located under the "Programs"-> "Start" menu, "adminstrative Tools" (Chinese Name: administrative tool), or open "ODBC data Source Administrator" from the Control Panel (Chinese name: Console), and then select the Connection pooling (connection Pooling) tab and double-click the SQL Server, select Pool connetions to this drive (use pool to connect the driver), and change the following time to a larger 60 seconds, such as 120.
If this is a SqlConnection shared connection, specify a value for the ConnectionString property connection lifetime numeric name, which by default is 0, which means that the connection will never be automatically removed from the pool. If a different value is specified, the value is compared to the creation time and the current time of the connection once the connection is returned to the pool. If the lifetime exceeds the value of the connection lifetime, the connection is removed from the pool.

The problem is that the connection to the database is not turned off, and it takes time for the system to recycle automatically. The solution is to change the size of the connection pool. Add the following code after the connection string:

Enlist=true; Pooling=true; Max Pool size=300; Min Pool size=0; Connection Lifetime=300;user Id=sa;packet size=1000
Packet size argument takes any integer value from 512 to 32767

The following two kinds of methods are available:

1, add the following statement to the web.config:

<system.web>

</system.web>

From MSDN Explanation:
HttpRuntime is to configure ASP.net HTTP run-time settings to determine how to handle the ASP. NET application requests.
Executiontimeout: Represents the maximum time limit, in seconds, that a request is allowed to execute
maxRequestLength: Indicates the maximum file upload size supported by asp.net. This restriction can be used to prevent denial of service attacks caused by a user passing a large number of files to the server. The specified size is in kilobytes. The default value is 4096 KB (4 MB).
useFullyQualifiedRedirectUrl: Indicates whether client redirection is fully qualified (in "Http://server/path" format, which is required for some mobile controls), or whether relative redirection is sent to the client instead. If true, all redirects that are not fully qualified are automatically converted to fully qualified formats. False is the default option.
minFreeThreads: Specifies the minimum number of free threads that are allowed to execute new requests. asp.net the specified number of threads to maintain a free State for requests that require additional threads to complete their processing. The default value is 8.
minLocalRequestFreeThreads: Represents the minimum number of free threads that the ASP.net maintains to allow the execution of new local requests. The number of threads is reserved for requests that are passed in from the local host in case some requests issue a child request to the local host during its processing. This avoids a possible deadlock caused by recursion to re-enter the WEB server.
appRequestQueueLimit: Represents the maximum number of requests that ASP.net will queue for an application. When there are not enough free threads to process the request, the request is queued. When the queue exceeds the limit specified in this setting, the incoming request is rejected through the "503-Server Too busy" error message.
Enableversionheader: Indicates whether the specified asp.net should output a version header. Microsoft Visual Studio 2005 uses this property to determine which version of ASP.net is currently in use. For a production environment, this property is not required and can be disabled.

2, the solution is very simple, in the code to find the command object such as SqlCommand object, give the CommandTimeout attribute a relatively large value. For example 60 seconds, the SqlCommand default timeout is 30 seconds. You can also set the SqlCommand timeout property to 0.

Note:

A value of 0 indicates no limit, and a value of 0 should be avoided in commandtimeout, otherwise the command will wait indefinitely.

[C #]
public void Createmysqlcommand ()
{
   SqlCommand mycommand = new SqlCommand ();
 & nbsp Mycommand.commandtimeout = 15;
   mycommand.commandtype = CommandType.Text;
} as:http://msdn.microsoft.com/library/chs/cpref/html/ Frlrfsystemdatasqlclientsqlcommandclasscommandtimeouttopic.asp?frame=true
   
sqldataadapter   da=   new   SqlDataAdapter ();  
da. selectcommand.commandtimeout   = 60; 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.