I want to create a web api application to connect xamarin with android.
I had tried a lot, but some connection errors are coming.
My code is given below:
public async Task<JsonValue> find(int ID)
{
using (HttpClient client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:49836");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage result = client.GetAsync("api/Product").Result;
return JsonConvert.DeserializeObject<JsonValue>(await result.Content.ReadAsStringAsync());
}
}
}
I 'm getting the error like the below
System.Net.WebException: Error: ConnectFailure (Connection refused) ---> System.Net.Sockets.SocketException: Connection refused
Can any one help. Any help is appreciated.