Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
HttpVersion Class

HttpVersion Class

Defines the HTTP version numbers supported by the HttpWebRequest and HttpWebResponse classes.

For a list of all members of this type, see HttpVersion Members.


[Visual Basic]
Public Class HttpVersion
public class HttpVersion
public __gc class HttpVersion
public class HttpVersion

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


The HttpVersion class defines the HTTP versions supported by the HttpWebRequest and HttpWebResponse classes. The HTTP version number is used to control version-specific features of HTTP, such as pipelining and chunking.


[Visual Basic, C#, C++] The following example demonstrates the use of HttpVersion.

[Visual Basic] 
' Create a 'HttpWebRequest' object.
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.microsoft.com"), HttpWebRequest)
Console.WriteLine(ControlChars.Cr + "The 'ProtocolVersion' of the protocol before assignment is :{0}", myHttpWebRequest.ProtocolVersion)
' Assign Version10 to ProtocolVersion.
myHttpWebRequest.ProtocolVersion = HttpVersion.Version10
' The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Console.WriteLine(ControlChars.Cr + "The 'ProtocolVersion' of the protocol after  assignment is :{0}", myHttpWebRequest.ProtocolVersion)
Console.WriteLine(ControlChars.Cr + "The 'ProtocolVersion' of the response object is :{0}", myHttpWebResponse.ProtocolVersion)

// Create a 'HttpWebRequest' object.
HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create("http://www.microsoft.com");
Console.WriteLine("\nThe 'ProtocolVersion' of the protocol before assignment is :{0}",myHttpWebRequest.ProtocolVersion);
// Assign Version10 to ProtocolVersion.
// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();
Console.WriteLine("\nThe 'ProtocolVersion' of the protocol after  assignment is :{0}",myHttpWebRequest.ProtocolVersion);
Console.WriteLine("\nThe 'ProtocolVersion' of the response object is :{0}",myHttpWebResponse.ProtocolVersion);

// Create a 'HttpWebRequest' object.
HttpWebRequest* myHttpWebRequest =
Console::WriteLine(S"\nThe 'ProtocolVersion' of the protocol before assignment is : {0}",
// Assign Version10 to ProtocolVersion.
// Assign the response Object* of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse* myHttpWebResponse=dynamic_cast<HttpWebResponse*>(myHttpWebRequest->GetResponse());
Console::WriteLine(S"\nThe 'ProtocolVersion' of the protocol after  assignment is : {0}",
Console::WriteLine(S"\nThe 'ProtocolVersion' of the response Object* is : {0}",

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Net

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: System (in System.dll)

See Also

HttpVersion Members | System.Net Namespace

© 2015 Microsoft