PRB: "Request Timed Out" Error Occurs When You Use the DataAdapter Method in an ASP.NET Application (825739)



The information in this article applies to:

  • Microsoft ASP.NET (included with the .NET Framework) 1.0
  • Microsoft ASP.NET (included with the .NET Framework 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

  1. Open the Web.config file in Notepad.
  2. 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> 
    
  3. Modify the value of the executionTimeout attribute to avoid time-out errors.
  4. Save the Web.config file.

Method 2: Set the ExecutionTimeout Attribute Value in the Machine.config File

  1. Open the Machine.config file in Notepad. The Machine.config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ directory.
  2. 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" />
  3. Modify the value of the executionTimeout attribute to avoid time-out errors.
  4. Save the Machine.config file.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Microsoft Visual Studio .NET version 2002.
  2. On the File menu, point to New, and then click Project.
  3. Click Visual Basic Projects under Project Types, and then click ASP.NET Web Application under Templates. By default, WebForm1.aspx is created.
  4. In Design view, right-click WebForm1, and then click View Code.
  5. 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
    
  6. 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>    
  7. Set the application to build in release mode. To do this, follow these steps:
    1. In Solution Explorer, right-click your project.
    2. Click Properties, and then click Configuration Manager.
    3. Click Release under Active Solution Configuration, and then click Close.
    4. Click OK.
  8. 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.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web sites:

Modification Type:MinorLast Reviewed:9/10/2003
Keywords:kbweb kbSqlClient kbDataAdapter kbHttpRuntime kbConfig kbThread kbprb KB825739 kbAudDeveloper