0

My kendoUI never fires destroy method ? What am I doing wrong. The grid show data properly but fails to delete the record.

$("#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 controller participant: tested on fiddler /api/participant/delete/2 works

    [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);
        }

    }

KendoGrid show error when click on Delete 405 Method Not Allowed, The requested resource does not support http method 'DELETE'

nam vo
  • 2,911
  • 11
  • 46
  • 69
  • 1
    Try changing the verb to HttpPost on controller and set type: "POST" in html. An example here http://demos.telerik.com/kendo-ui/grid/editing – SBirthare Nov 27 '14 at 05:22
  • The best and low cost solution is: change `httpdelete verb` to `httppost` verb – Amir Feb 13 '18 at 20:56

1 Answers1

1

This is not problem with Kendo, just with HttpDelete.

Problem is with WebDAV module and answears from this link work for me very well. In short just change your web.config:

<system.webServer>
    <modules>
      <remove name="WebDAVModule" />
    </modules>
    <handlers>
      <remove name="WebDAV" /> 
    </handlers>
</system.webServer>
Community
  • 1
  • 1
Jarosław Kończak
  • 3,287
  • 2
  • 15
  • 32