ASP. NET timeout has reached solution-

Source: Internet
Author: User

Solution
1. Close the unclosed connection in the code.
2. Expand the sharing pool as follows:
The solution is to modify the connection life of the Connection Pool, because the default value is 60 seconds, that is, the time when the connection can be saved in the pool after the application is released.
The procedure is as follows:
For ODBC, You can manually change it in ODBC data source administrator. The program is located in "programs"-> "Adminstrative Tools" in the "Start" menu) or open "ODBC data source administrator" (ODBC data source Manager) from "Control Panel" (Chinese name: Control Panel), and then select the "connection pool" tab, double-click "SQL Server" in the driver and select "pool ".
Connetions to this drive "(connect to the driver using the pool), change the following time to 60 seconds, for example, 120.
If it is a sqlconnection shared connection, specify a value for the connectionstring attribute connection Lifetime Value Name. This value is 0 by default, indicating that the connection will never be automatically removed from the pool. If a different value is specified, the value will be compared with the connection creation time and current time once the connection is returned to the pool. If the lifetime exceeds the value of connection lifetime, the connection will be removed from the pool.

The cause of the problem is that the connection to the database is not closed, and automatic recovery by the system takes time. 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
The packet size parameter is an integer between 512 and 32767.

 

There are two methods:

1. Add the following statement to Web. config:

<System. Web>

& Lt; httpruntime maxrequestlength = "102400"
Executiontimeout = "720"/>

</System. Web>

Explanation from msdn:
Httpruntime is used to configure ASP. net http runtime settings to determine how to process requests to ASP. NET applications.
Executiontimeout: maximum time limit allowed for request execution, in seconds
Maxrequestlength: indicates the maximum file upload size supported by ASP. NET. This restriction can be used to prevent DoS attacks caused by a large number of files being transferred to the server. The specified size is in KB. The default value is 4096 KB (4 MB ).
Usefullyqualifiedredirecturl: indicates whether the client redirection is fully qualified (in the "http: // server/path" format, which is required by some mobile controls ), or indicates whether to send relative redirection to the client. If it is true, all non-fully-qualified redirects are automatically converted to a fully-qualified format. False is the default option.
Minfreethreads: specifies the minimum number of free threads allowed to execute new requests. ASP. NET allows a specified number of threads to remain free by appending threads to complete the requests it processes. The default value is 8.
Minlocalrequestfreethreads: the minimum number of free threads allowed to execute new local requests maintained by ASP. NET. The number of threads is reserved for requests passed in from the local host to prevent some requests from sending subrequests to the local host during processing. This avoids the possibility of re-entering the Web by recursion.
The deadlock caused by the server.
Apprequestqueuelimit: indicates the maximum number of requests that ASP. NET will queue for the application. Requests are queued when there are not enough free threads to process requests. When the queue exceeds the limit specified in this setting, the "503-
The server is too busy. "The error message rejects incoming requests.
Enableversionheader: Specifies whether ASP. NET should output the version header. Microsoft Visual Studio 2005 uses this attribute to determine the current ASP. NET version. This attribute is not required for the production environment and can be disabled.

2. The solution is simple. Find the command object such as sqlcommand in the Code and assign a large value to the commandtimeout attribute. For example, for 60 seconds, the default timeout value of sqlcommand is 30 seconds. You can also set the timeout attribute of sqlcommand to 0.

Note:

The value 0 indicates that there is no limit. The value 0 should be avoided in commandtimeout; otherwise, the command will be waiting for execution indefinitely.

[C #]
Public void createmysqlcommand ()
{
Sqlcommand mycommand = new sqlcommand ();
Mycommand. commandtimeout = 15;
Mycommand. commandtype = commandtype. text;
}

See 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.