public async Task <ActionResult> Index() { WebClient client = new WebClient(); ForcastDetailModel forcastDetail = await client.GetForcastDetail(); return(View(forcastDetail)); }
public async Task <ForcastDetailModel> GetForcastDetail() { ForcastDetailModel forcastDetail = new ForcastDetailModel(); using (var response = await _client.GetAsync("http://localhost:51279/api/CountryModel/1")) { if (response.IsSuccessStatusCode) { string jsonString = await response.Content.ReadAsStringAsync(); forcastDetail = _jsonSerializer.Deserialize <ForcastDetailModel>(jsonString); } } return(forcastDetail); }