我试图从 Kendo Ui Grid 将数据发布到我的 web api
var crudServiceBaseUrl = "http://127.255.0.1:8081/api",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/meeting",
dataType: "jsonp",
},
update: {
type: "POST",
url: crudServiceBaseUrl + "/meeting/postmeeting",
contentType: "application/json; charset=utf-8",
dataType: 'json',
success: function (msg) {
alert("success");
}
},
.....
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
toolbar: ["create"],
columns: [
{ field: "Organizer", title: "Organizer" },
{ field: "Title", title: "Title" },
{ field: "Location", title: "Location", },
{ command: ["edit", "destroy"], title: " ", width: "160px" }],
editable: "inline"
});
但是当我更新时
我收到 405 错误
Request URL:http://127.255.0.1:8081/api/meeting/postmeeting
Request Method:OPTIONS
Status Code:405 Method Not Allowed
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:accept, origin, content-type
Access-Control-Request-Method:POST
Host:127.255.0.1:8081
Origin:http://localhost:30320
Proxy-Connection:keep-alive
有人可以向我解释一下 request Method 是如何变成 OPTION 的吗?因此,我的 ASP.NET Web API 中的 POST 方法没有调用
[HttpPost]
public HttpResponseMessage PostMeeting(MeetingEntity meeting)
{
_meetingRepository.Update(meeting);
return new HttpResponseMessage(HttpStatusCode.OK);
}