Resolving ASP. NET web applicatio timeout has reached. The timeout has expired before the operation is completed or the server has not responded

Source: Internet
Author: User
When I first arrived on Monday, the company asked me to solve the problem that the system had been residual. One of the channels could not be opened, and an error was reported, "the timeout time is up. The time-out period has expired or the server has not responded before the operation is completed"
The initial analysis reason is that the connection timed out during the MSSQL operation. I did not pay attention to this issue before, probably because I set the connection time limit in the configuration file and found a solution online, most of them are solved in database connection strings.

Sqlconnection con =   New Sqlconnection ( " Server =.; database = mydb; uid = sa; Pwd = password; " )

Changed:

Sqlconnection con =   New Sqlconnection ( " Server =.; database = mydb; uid = sa; Pwd = password; Connect timeout = 500 " )

It seems ineffective. If it is still running for 30 seconds, a timeout is reported!
Suddenly it seems that you can connect to the databaseCodeIndicates that the con attribute has a connectiontimeout,Sqlconnection con= NewSqlconnection ("Server =.; database = mydb; uid = sa; Pwd =;");
Con. connectiontimeout= 180;//Error. The connectiontimeout attribute is read-only!

The attempt failed, and then looked at the command object property, and found that it also has a similar property! Commandtimeout settings:

Sqlcommand cmd =   New Sqlcommand ();
Cmd. commandtimeout =   180 ;

Run again to solve the problem. The time set here is 180 seconds, that is, three minutes! You can set it as needed. If it is too long, you can also set it to 0. When this attribute is set to 0, there is no time limit. This attribute value should be used with caution. You also need to set the time limit for running HTTP requests in the web. config configuration file.

< System . Web >
< Httpruntime Maxrequestlength = "102400" Executiontimeout = "720"   />
</ System. Web >

The value is set to 720 seconds. The preceding maxrequestlength attribute is generally used to limit the size of uploaded files! The default value is generally 4096 KB (4 MB ).
Let's take a look at the explanations from msdn:
Httpruntime is used to configure Asp.net HTTP runtime settings to determine how to handle Asp.net applications. Program .
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 possible deadlocks caused by recursive re-entering the web 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 incoming request is rejected through the "503-the server is too busy" error message.
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.

Msdn: msnd official explanation

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.