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 ReadOnly Property ProtocolVersion As Version
Dim instance As HttpWebResponse
Dim value As Version

value = instance.ProtocolVersion

/** @property */
public Version get_ProtocolVersion ()

public function get ProtocolVersion () : Version

Property Value

A Version that contains the HTTP protocol version of the response.

Exception typeCondition


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.

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")
    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.

Uri ourUri = new Uri(url);

// Creates an HttpWebRequest for the specified URL. 
HttpWebRequest myHttpWebRequest = (HttpWebRequest)

// Sends the HttpWebRequest and waits for the response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)

// Ensures that only Http/1.0 responses are accepted. 
if (!myHttpWebResponse.get_ProtocolVersion().
    Equals(HttpVersion.Version10)) {
    Console.WriteLine("\nThe server responded with a version "
        + "other than Http/1.0");
else {
    if (myHttpWebResponse.get_StatusCode().
        Equals(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.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions