【发布时间】:2017-08-11 01:51:14
【问题描述】:
我有一个 POST 请求,它只有一个字符串参数
[HttpPost]
public IHttpActionResult CheckMfaEnabled([FromBody]string userEmail)//
{
var isMfaEnabled = //use another service to return true/false
return Ok(isMfaEnabled);
}
我这样称呼它
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:60099");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
StringContent content = new StringContent(JsonConvert.SerializeObject(userEmail), Encoding.UTF8, "application/json");
var response = client.PostAsync("api/MFA/CheckMfaEnabled", content).Result;
return response.IsSuccessStatusCode;
}
它让我 404 not found Error , 我想我调用 HTTPPOST 的方式有问题。 谁能帮帮我?
【问题讨论】:
标签: json asp.net-web-api http-post httpclient webapi2