KendoUI网格永远不会触发破坏方法

时间:2014-11-27 05:06:15

标签: asp.net-mvc kendo-ui telerik

我的kendoUI永远不会触发destroy方法?我究竟做错了什么。网格正确显示数据但无法删除记录。

$("#registration-grid").kendoGrid({
                    dataSource: {
                        type: "json",
                        transport: {
                            read: {
                                url: "@Html.Raw(Url.Action("List", "Participant"))",
                                type: "POST",
                                dataType: "json"                                  
                            },
                            destroy: {
                                url: "http://localhost:53669/api/participant/",
                                type: "DELETE",
                                dataType: "json"                                   
                            }
                        },
                        schema: { data: "Data", total: "Total", model: { id: "Id" } },
                        batch: false,                          
                    },
                    pageable: { ... },
                    editable: { mode: "inline" },                      
                    columns: [
                        {  field: "Id", title: "Id",  width:50,filterable: false },
                     { command: ["destroy"], title: " ", width: "250px" }
                    ]                      

                });

Web api控制器参与者:在fiddler / api / participant / delete / 2上进行测试

    [HttpDelete]
    public HttpResponseMessage Delete(int id)
    {
        var participant = _participantService.Get(p => p.Id == id);
        if (participant == null)
            return Request.CreateResponse(HttpStatusCode.BadRequest);
        try
        {
            _participantService.Delete(participant);
            return Request.CreateResponse(HttpStatusCode.OK);
        }
        catch (Exception)
        {
            return Request.CreateResponse(HttpStatusCode.BadRequest);
        }

    }

单击“删除405方法不允许”时KendoGrid显示错误,请求的资源不支持http方法“DELETE”

1 个答案:

答案 0 :(得分:1)

这与Kendo没有问题,只有HttpDelete。

WebDAV模块存在问题,this link的回答非常适合我。简而言之,只需更改您的web.config:

<system.webServer>
    <modules>
      <remove name="WebDAVModule" />
    </modules>
    <handlers>
      <remove name="WebDAV" /> 
    </handlers>
</system.webServer>