当我使用https时,使用httpclient进行的http请求不起作用

时间:2018-03-27 03:08:38

标签: c# http .net-core dotnet-httpclient

正如标题所说的那样。

普通http的例子:

 var c = new HttpClient
 {
 BaseAddress = new Uri("http://www.google.com.br")
 };
 var l = new List<Task<HttpResponseMessage>>();
 for (int i = 0; i < 5; i++)
 {
 l.Add(c.GetAsync(""));
 }

 await Task.WhenAll(l);

结果: enter image description here

https的例子:

 var c = new HttpClient
 {
 BaseAddress = new Uri("https://www.google.com.br")
 };
 var l = new List<Task<HttpResponseMessage>>();
 for (int i = 0; i < 5; i++)
 {
 l.Add(c.GetAsync(""));
 }

 await Task.WhenAll(l);

结果:

enter image description here

0 个答案:

没有答案