HttpClient超时不会影响

时间:2018-01-12 16:43:29

标签: c# httpclient

我有以下实现。我在100秒后收到超时异常。我已经向httpclient添加了10分钟,如下所示,但我仍然收到相同的错误消息。

using (var httpClient = new HttpClient(new HttpClientHandler()))
{
   httpClient.Timeout = TimeSpan.FromMinutes(10);
   var request = new HttpRequestMessage(method, requestUri);
   if (body != string.Empty)
   {
      request.Content = new StringContent(body, Encoding.UTF8, "application/json");
    }

    try
    {
       using (var response = httpClient.SendAsync(request).Result)
       {

       }
       catch (Exception ex)
       {

       }
     }
 }

0 个答案:

没有答案