我有以下实现。我在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)
{
}
}
}