I realized when click Backbone.Todos example "Clear x completed items" I get a DELETE 405 not allowed...
I understand from the pervious helps and docs that if I want to enable DELETE PUT PATCH ... I need to set
X-http-method-override : DELETE
if it was a form or in jquery.
But I am not sure how this is done in the Backbone.Todos example as I am new to backbone.js.
Could you please point out how to fix the DELETE 405 ? Thank you.
EDIT ---------------------------------------
I can always change routes to ...
[Route("/todos/add")] //C - post
[Route("/todos/{id}")] //R - get
[Route("/todos/{id}/edit")] //U - post
[Route("/todos/{id}/delete")] //D - post
So, only Post and Get are enough to do the job. But it doesn't look very Restful compare to:
[Route("/todos/{id}", "Delete")] //D - delete
Does it?
Backbone.js has special support for this, which you can enable with:
From their website:
emulateHTTP Backbone.emulateHTTP = true
The 405 response may be the result of having something else running in IIS like WebDav that will hijack the and reject the request before it reaches ServiceStack. Otherwise if it's being rejected on the client you may want to enable CORS to allow additional HTTP Verbs to be sent.
After some digging, I realized it is not the Backbone setting (which is
Backbone.emulateHTTP = false;
in line #34 of backbone.js by the way)I checked Fiddler and it says:
It was the WebDAV hijacking and rejecting the request as mythz suspected. Then I found out how to disable WebDAV from the web.config:
Now it works happily. Thank you!