【发布时间】:2014-05-19 07:44:42
【问题描述】:
我正在尝试从 jqGrid 调用 ASP.net WEB API 的 DELETE 方法。但是我收到消息 - “错误状态:'方法不允许'。错误代码:405”。
以下是详细信息。
JQGrid 代码-
$("#employeeSalarysGrid").jqGrid('navGrid', '#employeeSalarysPager',
{
add: true,
edit: true,
del: true
},
editOption,
addOption,
delOption);
var delOption = {
caption: "Delete",
msg: "Delete selected record(s)?",
bSubmit: "Delete", bCancel: "Cancel",
mtype: "DELETE",
url: 'http://localhost:50570/api/Test/'
};
ASP.NET Web API 方法:
public HttpResponseMessage Delete(string id)
{
//code for processing delete request
}
我已经跟踪了使用 Fiddler 发送的请求。以下是请求详情:
DELETE http://localhost:50570/api/Test HTTP/1.1
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://localhost:53055/Views/Test.aspx
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: localhost:50570
Content-Length: 13
Connection: Keep-Alive
Pragma: no-cache
oper=del&id=2
请注意参数 Id=2 是在请求正文中发送的,而不是查询字符串,我认为应该没问题。
请让我知道您对删除方法没有被调用的原因的看法。
【问题讨论】:
标签: jquery ajax asp.net-web-api jqgrid