HttpWebResponse.ProtocolVersion HttpWebResponse.ProtocolVersion HttpWebResponse.ProtocolVersion HttpWebResponse.ProtocolVersion Property

Definition

Ruft die in der Antwort verwendete Version des HTTP-Protokolls ab.Gets the version of the HTTP protocol that is used in the response.

public:
 property Version ^ ProtocolVersion { Version ^ get(); };
public Version ProtocolVersion { get; }
member this.ProtocolVersion : Version
Public ReadOnly Property ProtocolVersion As Version

Eigenschaftswert

Eine Version mit der Version des HTTP-Protokolls der Antwort.A Version that contains the HTTP protocol version of the response.

Ausnahmen

Die aktuelle Instanz wurde verworfen.The current instance has been disposed.

Beispiele

In diesem Beispiel wird ein HttpWebRequest und fragt nach einem HttpWebResponse.This example creates an HttpWebRequest and queries for an HttpWebResponse. Das Beispiel überprüft dann um festzustellen, ob der Server mit der gleichen Version reagiert.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();
        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");
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(); 
Dim ourUri As New Uri(url)
' Creates an HttpWebRequest with the specified URL. 
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(ourUri), HttpWebRequest)
myHttpWebRequest.ProtocolVersion = HttpVersion.Version10
' Sends the request and waits for the response.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
'The ProtocolVersion property is used to ensure that only Http/1.0 responses are accepted. 
If myHttpWebResponse.ProtocolVersion Is HttpVersion.Version10 Then
    Console.WriteLine(ControlChars.NewLine + "The server responded with a version other than Http/1.0")
Else
    If myHttpWebResponse.StatusCode = HttpStatusCode.OK Then
        Console.WriteLine(ControlChars.NewLine + "Request sent using version HTTP/1.0. Successfully received response with version Http/1.0 ")
    End If
End If
' Releases the resources of the response.
myHttpWebResponse.Close()

Hinweise

Die ProtocolVersion Eigenschaft enthält die Versionsnummer des HTTP-Protokolls der Antwort von der Internetressource gesendet werden.The ProtocolVersion property contains the HTTP protocol version number of the response sent by the Internet resource.

Gilt für: