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.

System_CAPS_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
Available since 1.1
Return to top
Show: