Reputation: 21226
I use always HttpGet or HttpPost even when my action is executing a delete method on the database.
For what should I use then HttpDelete/HttpPut ?
Upvotes: 12
Views: 18473
Reputation: 32768
I guess you have understood about the use of DELETE
request but PUT
is a little different thing.
If I'm creating a new resource in the server and if the URI through which it can be accessed is decided by me then I'll go for PUT
. In most of the cases the URI is decided by the server and hence POST
go for creation and PUT
usually for update.
Final thing is, like GET
both DELETE
and PUT
are idempotent, means how many times the client send the requests serially the state of the server should be changed to same as in the first request.
Upvotes: 2
Reputation: 40
Web browsers only support GET and POST, so if you are building a web site, there is no need for PUT or DELETE. If you are building a RESTful api, though, PUT and DELETE are the way to go if you want your users to be able to put and/or delete stuff.
EDIT: It seems browsers do support DELETE and PUT in their implementations of XMLHttpRequest. Hence you can use them in ajax requests. Html forms, though, do not support them.
Upvotes: 17
Reputation: 8214
If you build an OData service.
HTTP DELETE - Deletes the entity data that the specified resource represents. A payload is not present in the request or response messages.
HTTP PUT - Replaces existing entity data at the requested resource with new data that is supplied in the payload of the request message. (msdn)
There's a presentation with Scott Hanselman that might be interesting. (I haven't seen it yet.)
There's also a couple of lectures on pluralsight on OData if you have a subscription there.
Upvotes: 3