Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

How to: Access HTTP-Specific Properties 

This sample shows how to turn off the HTTP Keep-alive behavior and get the protocol version number from the Web server.

Example

HttpWebRequest HttpWReq = 
    (HttpWebRequest)WebRequest.Create("http://www.contoso.com");
// Turn off connection keep-alives.
HttpWReq.KeepAlive = false;

HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();

// Get the HTTP protocol version number returned by the server.
String ver = HttpWResp.ProtocolVersion.ToString();
HttpWResp.Close();

Compiling the Code

This example requires:

  • References to the System.Net namespace.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.