0

I implemented a WebAPI Odata V3 endpoint. I then used the WCF Data Services client in Silverlight to access the Odata endpoint. The GET, and the updates work great. However, when I try to submit a delete I see using Fiddler that the client is sending a POST and X-HTTP-Method: DELETE instead of a DELETE.

According to the documentation, the default behavior should be a DELETE request, but with a override of using the .UsePostTunneling = true; on the data service client to send the extension method. When I try to set UsePostTunneling = false; the authentication (Negotiate) fails making GETS fail as well.

Using Fiddler I can submit a DELETE request and it executes correctly, so it seems like the server works correctly.

What would cause the client to send a POST instead of a DELETE by default?

Greg Rotman
  • 97
  • 1
  • 10
  • possible duplicate of [DELETE method .NET WebAPI does not work](http://stackoverflow.com/questions/12313978/delete-method-net-webapi-does-not-work) – Aron Feb 12 '15 at 17:21
  • Its because IIS doesn't by default let you use "custom" HTTP verbs like Delete. The default ones are just GET and POST. – Aron Feb 12 '15 at 17:21
  • I'll try that. However, the DELETE method does work. The problem is the client is sending the request as a POST not a DELETE – Greg Rotman Feb 12 '15 at 17:28
  • Adding the verbs to the applicationHost.config file had no affect. The client still sent the request as a POST rather than a DELETE. – Greg Rotman Feb 12 '15 at 17:38
  • I've done some further research. In the WCF Client, the SendingRequest2 event does show a DELETE request is being created. So it is being changed to a POST event somewhere down the line. The Intelisense states that it could be change by the handler? Is there a way to control the handler? – Greg Rotman Feb 13 '15 at 13:46

1 Answers1

0

I wasn't able to find a way to change the behavior of the client. However, I did solve my problem. What I did was override the handler on the server side, and if the request was a POST with the x-HTTP-Method:Delete in the header I changed it to a DELETE request. This is detailed here: http://www.hanselman.com/blog/HTTPPUTOrDELETENotAllowedUseXHTTPMethodOverrideForYourRESTServiceWithASPNETWebAPI.aspx

Greg Rotman
  • 97
  • 1
  • 10