【发布时间】:2015-09-30 19:51:07
【问题描述】:
我正在使用 HttpClient 的操作方法中调用 POST,但我不确定它是否正确完成。我不需要它是异步的。基本上,如果在我的系统上成功创建用户,我会在另一个系统中创建他们。这是我正在调用的代码:
using (var client = new HttpClient())
{
var postData = new FormCollection();
postData["api_token"] = ConfigurationManager.AppSettings["ApiToken"];
postData["api_action"] = "Save";
postData["customer_email"] = userName;
postData["customer_password"] = password;
var result = client.PostAsync(string.Format("{0}/api", ConfigurationManager.AppSettings["Url"]), content).Result;
var xmlResponse = result.Content.ReadAsStringAsync().Result;
}
【问题讨论】:
-
你的问题到底是什么?
-
@ToddMenier - 我说的对吗?
标签: c# asp.net-mvc-4 dotnet-httpclient