HttpResponseMessage 调用.net web api
// // GET: /Home/ //释迦苦僧 public ActionResult Index() { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:12899/"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.GetAsync("api/task").Result; if (response.IsSuccessStatusCode) { var tasks = response.Content.ReadAsStringAsync(); List<TaskInfoModel> p = JsonConvert.DeserializeObject<List<TaskInfoModel>>(tasks.Result); Console.Write(tasks.Result); } return View(); }
生活不易,五行缺金,求打点
![](http://files.cnblogs.com/files/woxpp/QQ%E6%88%AA%E5%9B%BE20161229110254.bmp)