I have published my Web API on IIS and when I am consuming it in my Xamarin Android App, it is throwing error i.e., Connection Failure. I have written this code:-
public HotDogRepository()
{
Task.Run(() => this.LoadDataAsync(url)).Wait();
}
private async Task LoadDataAsync(string uri)
{
try
{
if (hotDogGroups != null)
{
string responseJsonString = null;
using (var httpClient = new HttpClient())
{
Task getResponse = httpClient.GetAsync(uri);
HttpResponseMessage response = await getResponse;
responseJsonString = response.Content.ReadAsStringAsync().Result;
hotDogGroups = JsonConvert.DeserializeObject >(responseJsonString);
}
}
}
catch (Exception ex)
{
throw;
}
}


Ravindra SinghRank #2,791 · 506 reputationPosted Apr 20, 2018, 2:42 AM EDT
> Get()
>(response.Content.ReadAsStringAsync().Result);
Deepak VermaRank #3,278 · 438 reputationPosted May 8, 2018, 9:17 PM EDT