Ola, quando o block catch tenta jogar a exception, o app fecha, e aparece essa mensagem no visual studio. Exception Unhandled Java.Net.UnknownHostException Message=Unable to resolve host "aluracar.herokuapp.com": No address associated with hostname
Coloquei um break point no exception e do catch, e ele mostrou a mesma exception acima.
try
{
using (var client = new HttpClient())
{
var fillForm = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string,string>("email",login.Email),
new KeyValuePair<string,string>("senha",login.Password)
});
client.BaseAddress = new Uri("https://aluracar.herokuapp.com/login");
var result = await client.PostAsync("/login", fillForm);
if (result.IsSuccessStatusCode)
MessagingCenter.Send<User>(new User(), "SuccessLogin");
else
MessagingCenter.Send<LoginException>(new LoginException("User or Password Incorrect!"), "FailLogin");
}
}
catch (Exception e)
{
MessagingCenter.Send<LoginException>(new LoginException("Connection Failed! Please check your internet connection and try again later!"), "FailLogin ");
throw;
}