Microsoft KB Archive/825739

= PRB: &quot;Request Timed Out&quot; Error Occurs When You Use the DataAdapter Method in an ASP.NET Application =

Article ID: 825739

Article Last Modified on 11/26/2007

-

APPLIES TO


 * Microsoft ASP.NET 1.0
 * Microsoft ASP.NET 1.1

-



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



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



WORKAROUND
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:     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.</li>  In the Machine.config file, locate the httpRuntime element. The Web.config file is located in the Web Application directory <httpRuntime executionTimeout=&quot;90&quot; maxRequestLength=&quot;4096&quot; useFullyQualifiedRedirectUrl=&quot;false&quot; minFreeThreads=&quot;8&quot; minLocalRequestFreeThreads=&quot;4&quot; appRequestQueueLimit=&quot;100&quot; /> </li> Modify the value of the executionTimeout attribute to avoid time-out errors.</li> Save the Machine.config file.</li></ol>

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce the Behavior
 Start Microsoft Visual Studio .NET version 2002.</li> On the File menu, point to New, and then click Project.</li> Click Visual Basic Projects under Project Types, and then click ASP.NET Web Application under Templates. By default, WebForm1.aspx is created.</li> In Design view, right-click WebForm1, and then click View Code.</li>  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


 * 1) Region &quot; Web Form Designer Generated Code &quot;

'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


 * 1) 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 = &quot;server=servername;uid=sa;pwd=password;database=testdatabase;&quot; 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(&quot;Select top 60000 * From timelog (nolock)&quot;, objConn) Dim myDs As DataSet myDs = New DataSet(&quot;testTimelog&quot;) Dim dt As DateTime dt = New DateTime dt = dt.Now Response.Write(&quot;StartTime of DataAdapter fill - &quot; + dt) daAuthors.Fill(myDs, &quot;testTimelog&quot;)

dt = New DateTime dt = dt.Now Response.Write(&quot; EndTime of DataAdapter fill - &quot; + dt) Response.Write(&quot; No of Rows = &quot; + myDs.Tables(0).Rows.Count.ToString)

Catch ex As Exception Response.Write(ex.ToString) End Try

End Sub

End Class </li>  Open the Web.config file in Notepad, and then set the value for the Debug attribute to false as follows:  <compilation defaultLanguage=&quot;vb&quot; debug=&quot;false&quot; /> </system.web> </li> Set the application to build in release mode. To do this, follow these steps:  In Solution Explorer, right-click your project.</li> <li>Click Properties, and then click Configuration Manager.</li> <li>Click Release under Active Solution Configuration, and then click Close.</li> <li>Click OK.</li></ol> </li> <li>On the Debug menu, click Start to build and run the project. You may receive the error message that the &quot;Symptoms&quot; section describes.</li></ol>

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.

<div class="references_section">