SB2*_*055 5 ajax json asp.net-web-api
我有以下内容:
[HttpDelete]
public HttpResponseMessage DeleteFolder(int[] ids)
{
Run Code Online (Sandbox Code Playgroud)
而我正试图用这个:
DELETE http://localhost:24144/api/folder/1483;
DELETE http://localhost:24144/api/folder/[1483]
Run Code Online (Sandbox Code Playgroud)
但是这些在delete方法中都是null - 如何在不将数据放入正文的情况下发送数据(因为这是DELETE请求)?
我的路由有这个:
routes.MapHttpRoute(
name: "Folder",
routeTemplate: "api/folder/{id}",
defaults: new { controller = "Folder", id = RouteParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
SB2*_*055 13
没关系,我发现了这个:
http://blog.codelab.co.nz/2012/10/16/passing-arrays-into-asp-net-web-api-as-parameters/
虽然无法在SO上找到答案,但我会留在这里.
从以上链接页面中摘录:
[HttpGet()]
public HttpResponseMessage FindByMembers([FromUri]Int32[] ids = null)
{
//Do stuff
return Request.CreateResponseMessage(HttpStatusCode.OK);
}
Run Code Online (Sandbox Code Playgroud)
网址为http:// mywebsite/api/mycontroller/findbymembers /?ids = 1&ids = 2&ids = 3.
| 归档时间: |
|
| 查看次数: |
8753 次 |
| 最近记录: |