HttpWebResponse::ProtocolVersion Property
.NET Framework 4.5
Gets the version of the HTTP protocol that is used in the response.
Namespace: System.Net
Assembly: System (in System.dll)
| Exception | Condition |
|---|---|
| ObjectDisposedException | The current instance has been disposed. |
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 = gcnew 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" ); } else 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. myHttpWebResponse->Close();
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.