-
转载:https://blog.youkuaiyun.com/Anlan2010/article/details/49445905
-
public ActionResult Index()
-
{
-
var requestJson = JsonConvert.SerializeObject("[{'CityId':18,'CityName':'西安','ProvinceId':27,'CityOrder':1},{'CityId':53,'CityName':'广州','ProvinceId':27,'CityOrder':1}]");
-
HttpContent httpContent = new StringContent(requestJson);
-
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
-
var httpClient = new HttpClient();
-
var responseJson = httpClient.PostAsync("http://localhost:6972/api/test/Post/", httpContent)
-
.Result.Content.ReadAsStringAsync().Result;
-
ViewBag.s = responseJson;
-
return View();
-
}
.NET MVC4 用HttpClient后台post 请求webapi
最新推荐文章于 2022-11-03 16:46:05 发布