【发布时间】:2015-12-17 13:24:38
【问题描述】:
我有一个托管在 IIS 10(Windows Server 2016)上的 asp.net Web api。当我从 Microsoft Edge 浏览器向它发出 GET 请求时,我看到在 IIS 日志中使用了 HTTP 2.0
2015-09-20 21:57:59 100.76.48.17 GET /RestController/Native - 443 - 73.181.195.76 HTTP/2.0 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/42.0.2311.135+Safari/537.36+Edge/12.10240 - 200 0 0 7299
但是,当通过.net 4.6 client 发出GET 请求时,如下所示,
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://myapp.cloudapp.net/");
HttpResponseMessage response = await client.GetAsync("RestController/Native");
if (response.IsSuccessStatusCode)
{
await response.Content.CopyToAsync(new MemoryStream(buffer));
}
}
我在服务器日志中看到以下HTTP 1.1登录
2015-09-20 20:57:41 100.76.48.17 GET /RestController/Native - 443 - 131.107.160.196 HTTP/1.1 - - 200 0 0 707
如何让 .net 客户端使用 HTTP/2.0?
【问题讨论】:
标签: c# asp.net http http2 iis-10