【发布时间】:2022-02-21 20:15:02
【问题描述】:
我正在尝试发出 HTTP/2.0 请求,但无法正常工作。根据这个和其他帖子https://stackoverflow.com/a/53776383/18171693.NET > 3.0 应该支持它,但我无法让它工作。
Debug.WriteLine("Version:"+ Environment.Version.ToString());
var client = new HttpClient();
var req = new HttpRequestMessage(HttpMethod.Get,"https://http2.akamai.com/demo")
{
Version = new Version(2, 0)
};
var x = await client.SendAsync(req);
上面的代码生成:
Version:4.0.30319.42000
Exception thrown: 'System.ArgumentException' in mscorlib.dll
An exception of type 'System.ArgumentException' occurred in mscorlib.dll but was not handled in user code
Only HTTP/1.0 and HTTP/1.1 version requests are currently supported.
【问题讨论】:
标签: c# http2 httpconnection