I have an async Call from MVC Controller to another WebAPI. This piece of code was working for 3-4 years, without issues. Now, we had to move the Code to a different server environment. The website keeps working for 24 hours, exactly after 24 hours, the async calls to the Web API, start returning task cancelled exception. An app pool refresh for the API solves the issue.
When the "task cancelled exception" comes up, the API doesnt log any incoming requests. But when i make a request from Postman, the API returns results and logs the call as well.
below is the HTTP Client that makes the call to the WebAPI
using (var client = new HttpClient())
{
client.SetBearerToken(GetToken());
using (var content = new MultipartFormDataContent())
{
var response = await client.PostAsync(uri, content);
return response.Content.ReadAsAsync<T>().Result;
}
}```
[![App Pool settings for API][1]][1]
[1]: https://i.stack.imgur.com/2EIix.png