When you use the
DataAdapter.Fill method, or you run a query in
an ASP.NET Web application that takes more than 90 seconds to process, you may receive
the following error message:
HttpException (0x80004005):
Request timed out.
Note This error occurs only when you run the Web application in release
mode, and the value of the
Debug attribute in the Web.Config file is set to
false.
By default, the value of the
executionTimeout attribute is
set to 90 seconds in the Machine.config file. This error occurs when the
processing time exceeds 90 seconds.
To work around this problem, increase the time-out value that is set
for the
executionTimeout attribute in the configuration file.
The
executionTimeout attribute exists under httpRequest in the Machine.config file.
You can change these settings either in the Web.Config file or in the
Machine.config file. The default value for the time-out is 90 seconds. The
executionTimeout attribute indicates the maximum number of seconds a request is
permitted to run before being shut down by the ASP.NET Web application.
Method 1: Set the ExecutionTimeout Attribute Value in the Web.config File
- Open the Web.config file in Notepad.
- Add the httpRuntime element in the system.web section as follows:
<configuration>
<system.web>
<httpRuntime executionTimeout="90" maxRequestLength="4096" useFullyQualifiedRedirectUrl="false"
minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
</system.web>
</configuration>
- Modify the value of the executionTimeout attribute to avoid time-out errors.
- Save the Web.config file.
Method 2: Set the ExecutionTimeout Attribute Value in the Machine.config File
- Open the Machine.config file in Notepad. The
Machine.config file is located in the
%SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\
directory.
- In the Machine.config file, locate the httpRuntime element. The Web.config file is located in the Web Application directory
<httpRuntime executionTimeout="90" maxRequestLength="4096" useFullyQualifiedRedirectUrl="false"
minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
- Modify the value of the executionTimeout attribute to avoid time-out errors.
- Save the Machine.config file.
This
behavior is by design.
Steps to Reproduce the Behavior
- Start Microsoft Visual Studio .NET version 2002.
- On the File menu, point to New, and then click Project.
- Click Visual Basic Projects under Project Types, and then click ASP.NET Web
Application under Templates. By default,
WebForm1.aspx is created.
- In Design view, right-click WebForm1,
and then click View Code.
- To add the
database connection and the DataAdapter method to fill the dataset, replace the existing code with the following code:
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'The Web Form Designer requires this call.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: The Web Form Designer requires this method call
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim sConnectionString As String
sConnectionString = "server=servername;uid=sa;pwd=password;database=testdatabase;"
Dim objConn As SqlConnection
objConn = New SqlConnection(sConnectionString)
objConn.Open()
Dim daAuthors As SqlDataAdapter
'Increase the no.of records from existing value, if execution time is less than 90 sec.
daAuthors = New SqlDataAdapter("Select top 60000 * From timelog (nolock)", objConn)
Dim myDs As DataSet
myDs = New DataSet("testTimelog")
Dim dt As DateTime
dt = New DateTime()
dt = dt.Now
Response.Write("StartTime of DataAdapter fill - " + dt)
daAuthors.Fill(myDs, "testTimelog")
dt = New DateTime()
dt = dt.Now
Response.Write("<br>EndTime of DataAdapter fill - " + dt)
Response.Write("<br>No of Rows = " + myDs.Tables(0).Rows.Count.ToString())
Catch ex As Exception
Response.Write(ex.ToString())
End Try
End Sub
End Class
- Open the Web.config file in Notepad, and then set the value
for the Debug attribute to false as
follows:
<configuration>
<system.web>
<compilation defaultLanguage="vb" debug="false" />
</system.web>
</configuration> - Set the application to build in release mode. To do this, follow these steps:
- In Solution Explorer, right-click your project.
- Click Properties, and then click
Configuration Manager.
- Click Release under Active
Solution Configuration, and then click
Close.
- Click OK.
- On the Debug menu, click
Start to build and run the project. You may receive the
error message that the "Symptoms" section describes.
Note The default value for the time-out as set in the Machine.config
file is 90 seconds. If the process time is less than 90 seconds,
increase the
processing time by increasing the number of records to be fetched.
For more information, visit the following Microsoft Developer Network (MSDN) Web
sites:
Article ID: 825739 - Last Review: November 26, 2007 - Revision: 1.6
APPLIES TO
- Microsoft ASP.NET 1.0
- Microsoft ASP.NET 1.1
| kbweb kbsqlclient kbdataadapter kbhttpruntime kbconfig kbthread kbprb KB825739 |