0
votes

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?

1
possible duplicate of DELETE method .NET WebAPI does not workAron
Its because IIS doesn't by default let you use "custom" HTTP verbs like Delete. The default ones are just GET and POST.Aron
I'll try that. However, the DELETE method does work. The problem is the client is sending the request as a POST not a DELETEGreg Rotman
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
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

1 Answers

0
votes

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