Hi Team,
We are using ASP.NET Core 3.1 and making API calls using httpclient with "GetASync" and "PostAsync" methods. During concurrent calls, the API thread is getting terminated / cancelled with below exception. Could you please help to know how to handle this error and resolve this issue for concurrent user calls?
Code Sample:
var clientt = new HttpClient();
client.Timeout = Timespan.FromSeconds (120);
clientt.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = clientt.PostAsync(uri, content).Result;
response.Wait();
string resultString = response.Content.ReadAsStringASync().result;
Exception:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait()