FIX: Intermittent "Underlying connection was closed" error message when you call a Web service from ASP.NET


When you call a Microsoft ASP.NET Web service from an ASP.NET application, you may intermittently receive the following error message:
The underlying connection was closed: An unexpected error occurred on a send.
The call stack is similar to the following:
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send.
At System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) at
System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at


A supported hotfix is now available from Microsoft. However, it is intended to correct only the problem that is described in this article. Apply it only to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft .NET Framework service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Customer Support Services to obtain the hotfix. For a complete list of Microsoft Customer Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.

Date Time Version Size File name Platform
01-May-2003 12:48 1.0.3705.426 20,480 Perfcounter.dll X86
01-May-2003 12:48 1.0.3705.426 1,175,552 System.dll X86
01-May-2003 12:48 1.0.3705.426 311,296 System.runtime.remoting.dll X86
01-May-2003 12:48 1.0.3705.426 503,808 X86
This hotfix is included in the .NET Framework 1.0 Service Pack 3 and in the .NET Framework 1.1 Service Pack 1.

For more information about how to obtain the latest .NET Framework 1.0 service pack, click the following article number to view the article in the Microsoft Knowledge Base:

318836 How to obtain the latest .NET Framework 1.0 service pack


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

More Information

The error message that is mentioned in the "Symptoms" section may also occur for valid reasons. For example, the underlying connection may have been closed for reasons that are beyond the control of the client. In such circumstances, the Microsoft .NET Framework is behaving correctly.

For example, if the Web services that are called are hosted in a software or in a hardware load-balanced environment that contains servers that support HTTP 1.1 and keep-alive connections, the connection may have ended by the time that the client tries to reuse the connection. If this error still occurs after you apply this fix, try the following solutions:
  • Configure the Web site that hosts the Web services not to use keep-alive connections. To do this, follow these steps:
    1. Open the Microsoft Internet Information Server (IIS) Management Console and locate the Web server.
    2. Click the Web Site tab of the Properties page for the Web site.
    3. Click to clear the HTTP Keep-Alives Enabled check box.
  • Verify that your load-balancing hardware or software is correctly configured for your application requirements.
  • If you do not have control over the server environment that hosts the Web services that you are calling, you may have to disable keep-alive connections on the client side. To do this, follow these steps:
    1. Set the KeepAlive property of the
      HttpWebRequest class to false.
    2. Override the HttpWebRequest method in the Reference.cs file that is generated by Microsoft Visual Studio .NET for the Web client proxy. The following code overrides the HttpWebRequest method.
      protected override WebRequest GetWebRequest(Uri uri)
      HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);

      webRequest.KeepAlive = false;

      return webRequest;


For more information about how to obtain the .NET Framework 1.1 Service Pack 1, click the following article number to view the article in the Microsoft Knowledge Base:

885055 How to obtain Microsoft .NET Framework 1.1 Service Pack 1


ID do Artigo: 819450 - Última Revisão: 07/12/2007 - Revisão: 1