After the release of MVC 2, I have started to check and play with the new features, but i couldn't understand what is the use of PUT
and DELETE
verbs.
I have searched about it and read some articles but I couldn't get it.
What is the main purpose of DELETE
and PUT
? Do they have any advantages over using a GET
or POST
method instead (even though I can handle all of the requests with GET and POST)?
GET: Only function is to send information back to the client. It should be a repeatable operation without side effects.
POST: It does operations with side effects. It is not repeatable (if you POST twice, the server acts twice). After operation it should redirect to another page to show the results using GET.
DELETE: Its only function is to do a destructive operation, not repeatable (once the object is deleted, there is nothing else to delete).
PUT: Its function is to modify a single object and update it with the values sent in a POST (like) way. Repeatable.
You can fake DELETE and PUT with POST (as some web browsers don't recognize DELETE and PUT).
Please, use GET only to display information, not for operations with side effects.