This is a migrated thread and some comments may be shown as answers.

Rest CRUD methods

2 Answers 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jarle
Top achievements
Rank 1
Jarle asked on 09 Apr 2014, 11:15 PM
I have a little problem with the MVC datasource configuration of the grid.
I want to be able to specify a unique URL per row for the Update and Delete method of the datasource (ajax enabled).

My configuration right now looks like this:

// Removed other configurations here...
.DataSource(dataSource => dataSource
          .Ajax()
// Removed other configurations here...
          .Read(i => i.Route(RouteNames.ReadRoute)) // This should point to /api/users + GET
          .Create(i => i.Route(RouteNames.CreateRoute).Type(HttpVerbs.Post)) // This should point to /api/users + POST
          .Update(i => i.Route(RouteNames.UpdateRoute, new { id = ????? }).Type(HttpVerbs.Put)) // This should point to /api/users/{id} + PUT
          .Destroy(i => i.Route(RouteNames.DeleteRoute, new { id = ????? }).Type(HttpVerbs.Delete)) // This should point to /api/users/{id} + DELETE

There seems to be some problems with Kendo not supporting REST specifications.
First of; The Read method CANNOT be a GET, it must be a POST (is this correct and why?)
Secondly, and more important; The Update and Destroy NEEDS to be in the form of /collection/{id}

So for each row, I would have different Update and Delete urls where the {id} part varies.
This can be solved if I configure the datasource using javascript by setting the url of the create and delete methods to a javascript function.
But unfortunately this isn't possible in MVC - why?

Kind regards
Richard

2 Answers, 1 is accepted

Sort by
0
Jarle
Top achievements
Rank 1
answered on 09 Apr 2014, 11:55 PM
To answer my own question:
Have a look at this thread http://www.telerik.com/forums/using-put-and-delete-for-datasource-actions - it gives you the answer
0
Jarle
Top achievements
Rank 1
answered on 09 Apr 2014, 11:58 PM
And another thing. I got a 404 as soon as I set the AcceptVerbs to Put on the controller action. The reason for this is because MVC doesn't support PUT and DELETE by default so you need to configure / enable this either in the IIS configuration or the web.config of your application.

<system.webServer>
...
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
...
  </system.webServer>
Tags
Grid
Asked by
Jarle
Top achievements
Rank 1
Answers by
Jarle
Top achievements
Rank 1
Share this question
or