For some weird reason I don't understand, HTTP is a key part of Windows. It's integrated into Windows so much that in order to get WebSockets server support, you had to upgrade your PC to Windows 8 or Windows Server 2012.
Similarly, to get HTTP/2 server support, you have to upgrade your machine to Windows 10 or Windows Server 2016.
Windows 10 version 1607 (also known as "Anniversary Edition") added support for HTTP/2 to WinHTTP, so that you could now use it to connect to HTTP/2 servers.
Unfortunately, the .NET Framework has no update (yet) that takes advantage of this feature, as the calling code has to explicitly set an option to enable HTTP/2 support.
The good news is that .NET Core gained support with .NET Core 1.1's release last month. Even better, you can use the .NET Core library with the full .NET Framework.
To do this, you'll need to add a reference to System.Net.Http
(version 4.3.0 or higher) on NuGet. Then, use the HttpClient
and HttpRequestMessage
classes from that assembly.
The last thing you'll need to do is set myHttpRequestMessage.Version = new Version(2, 0)
in your code for each HttpRequestMessage
that you create.
With this property set, the HttpClient
's internal handler will attempt to use HTTP/2 when available, and fall back to HTTP/1.1 when it is not.