public async Task <ActionResult> Index()
        {
            WebClient          client        = new WebClient();
            ForcastDetailModel forcastDetail = await client.GetForcastDetail();

            return(View(forcastDetail));
        }
示例#2
0
        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);
        }