Export (0) Print
Expand All

HttpWebRequest.KeepAlive Property

Gets or sets a value that indicates whether to make a persistent connection to the Internet resource.

Namespace:  System.Net
Assembly:  System (in System.dll)

member KeepAlive : bool with get, set

Property Value

Type: System.Boolean
true if the request to the Internet resource should contain a Connection HTTP header with the value Keep-alive; otherwise, false. The default is true.

Set this property to true to send a Connection HTTP header with the value Keep-alive. An application uses KeepAlive to indicate a preference for persistent connections. When the KeepAlive property is true, the application makes persistent connections to the servers that support them.

NoteNote

When using HTTP/1.1, Keep-Alive is on by default. Setting KeepAlive to false may result in sending a Connection: Close header to the server.

The following code example sets the KeepAlive property to false to avoid establishing a persistent connection with the Internet resource.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft