我有一个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找不到错误, 我想我调用HTTPPOST的方式有问题。 有人可以帮帮我吗?