public async Task <T> PostAsJson <T>(string action, object value) { var client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = await client.PostAsync($"{_homeHubConnection.GetUrl()}/{action}", new JsonContent(value)); return(response.ContentAs <T>()); }
public async Task <bool> IsOnline() { try { var client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = await client.GetAsync($"{HomeHubConnection.GetUrl()}/isonline"); return(response.ContentAs <bool>()); } catch (Exception e) { return(false); } }