【发布时间】:2020-08-27 05:20:08
【问题描述】:
我正在尝试通过在 url 中发送参数来调用 HttpDelete RESTful Web API 方法。调用成功。
例子
string url = path + "deletemethodName?Id=" + Convert.ToInt32(idpamameter) + "&name=" + nameParameter;
using (HttpClient client = new HttpClient())
{
using (HttpResponseMessage response = client.DeleteAsync(url).Result)
{
if (response.IsSuccessStatusCode)
{
return Json(response.Content.ReadAsStringAsync().Result);
}
}
}
有没有办法——在调用 HttpDelete 方法时,就像我们使用在 body 中发送模型数据调用 POST 方法和在 API 方法中使用 [FromBody] 来访问模型数据而不是在网址?
由于我的 HttpDelete 方法中有超过 5 个参数要附加到 URL 中 - 我希望发送模型数据。
提前致谢。
【问题讨论】:
标签: c# asp.net-mvc asp.net-web-api2 webapi http-delete