FIX: .NET Framework 4.5-based HttpWebRequest and HttpClient classes terminate server connection in Windows 8, Windows RT and Windows Server 2012

Applies to: .NET Framework 4.5Windows 8Windows RT

Symptoms


Assume that you use the HttpWebRequest class or the HttpClient class in .NET Framework 4.5 to send a request to the server. In this situation, after the request is made and the HTTP response is chunked, server connection is terminated.

Note This issue typically occurs after you apply the update that is described in the following Knowledge Base (KB) article:
2750149 An update is available for the .NET Framework 4.5 in Windows 8, Windows RT and Windows Server 2012: January 2013

Resolution


To make sure that the HttpWebRequest class and the HttpClient class will reuse a connection, you must drain the entire HTTP request responses from the connection before a new request can be made. To deal with this issue, apply one of the following methods:
  • Make sure that you completely drain the response stream before you send a new request. For example, when you receive a chunked response, the application reads the response stream until the read method on the stream returns "0 bytes read." 

    Note This approach requires no additional update to be installed.
  • Install this update to restore the same behavior prior to the installation of the hotfix in KB 2750149. When the application closes the response stream, the HttpWebRequest class tries to drain the responses. If this operation is successful, the connection will be reused for the next request.

Hotfix Information

A supported hotfix is now available from Microsoft. However, it is intended to correct only the problem that this article describes. Apply it only to systems that are experiencing this specific problem.

To resolve this problem, 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 website: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.


Prerequisites

To apply this hotfix, you must have Microsoft .NET Framework 4.5 installed.

Restart requirement

You must restart the computer after you apply this hotfix if affected files are being used during the installation. We recommend that you close all applications that use .NET Framework before you apply this hotfix.