Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.

System.Object
   System.Net.HttpVersion

[Visual Basic]
Public Class HttpVersion
[C#]
public class HttpVersion
[C++]
public __gc class HttpVersion
[JScript]
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.

Remarks

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.

Example

[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)

[C#] 
// 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.
myHttpWebRequest.ProtocolVersion=HttpVersion.Version10;
// 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);

[C++] 
// Create a 'HttpWebRequest' object.
HttpWebRequest* myHttpWebRequest =
   dynamic_cast<HttpWebRequest*>(WebRequest::Create(S"http://www.microsoft.com"));
Console::WriteLine(S"\nThe 'ProtocolVersion' of the protocol before assignment is : {0}",
   myHttpWebRequest->ProtocolVersion);
// Assign Version10 to ProtocolVersion.
myHttpWebRequest->ProtocolVersion=HttpVersion::Version10;
// 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}",
   myHttpWebRequest->ProtocolVersion);
Console::WriteLine(S"\nThe 'ProtocolVersion' of the response Object* is : {0}",
   myHttpWebResponse->ProtocolVersion);

[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.

Requirements

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.