I'm trying to intercept the HTTP client error in case the server is non-existent or down.
i use this code:
HttpResponseMessage response;
try
{
response = await _client.GetAsync("CallApiXamarin/" + User);
}
catch (Exception ex) when (ex is TaskCanceledException || ex is OperationCanceledException)
{
throw;
}
But the APP hangs in debugging by showing this message:
Unhandled Exception:
System.Threading.Tasks.TaskCanceledException: A task was canceled.
What should I do?