Export (0) Print
Expand All

HttpWebResponse.ProtocolVersion Property

Gets the version of the HTTP protocol that is used in the response.

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

public Version ProtocolVersion { get; }

Property Value

Type: System.Version
A Version that contains the HTTP protocol version of the response.


The current instance has been disposed.

The ProtocolVersion property contains the HTTP protocol version number of the response sent by the Internet resource.

This example creates an HttpWebRequest and queries for an HttpWebResponse. The example then checks to see if the server is responding with the same version.

            Uri ourUri = new Uri(url);
				// Creates an HttpWebRequest for the specified URL. 
				HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(ourUri); 
				myHttpWebRequest.ProtocolVersion = HttpVersion.Version10;
				// Sends the HttpWebRequest and waits for the response.
				HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); 
				// Ensures that only Http/1.0 responses are accepted.  
				if(myHttpWebResponse.ProtocolVersion != HttpVersion.Version10)
					Console.WriteLine("\nThe server responded with a version other than Http/1.0");
				if (myHttpWebResponse.StatusCode == HttpStatusCode.OK)
					Console.WriteLine("\nRequest sent using version Http/1.0. Successfully received response with version HTTP/1.0 ");
				// Releases the resources of the response.

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft