我尝试将数据从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
有人可以向我解释请求方法如何成为OPTION? 因此,我的ASP.NET Web API中的POST方法不会调用
[HttpPost]
public HttpResponseMessage PostMeeting(MeetingEntity meeting)
{
_meetingRepository.Update(meeting);
return new HttpResponseMessage(HttpStatusCode.OK);
}