So, I'm building a Xamarin.Forms app and I made a little helper function for my requests to my Web API
public async static Task MakeGetRequest(string parameters, string url = null, bool hasISBN = false)
{
if(Bearer == null)
{
//bearer = await GetAuthToken();
}
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Bearer);
var response = await client.GetAsync(string.Format("{0}/{1}", string.IsNullOrEmpty(url) ? baseUrl : url, parameters));
var responseString = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<ResponseType>(responseString);
}
}
All the calls to the API are awaited, and I'm making the calls using the IP, not to localhost.
But after a few requests, I'm starting to get the error "A task was canceled" on API calls.
If I deploy the API to Azure and make the calls there I'm not getting that error. Happens on UWP, Android and iOS.
Has anyone else encountered a similar problem?
Thanks