Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does HTTP DELETE verb return 405 error - method not allowed for my RESTful WCF service running on IIS 7.5?

Can anyone shed any light on this? I feel like I have wasted the entire day today hunting and searching the internet for any scrap of information about how to do this. I have created a very simple WCF RESTful service. It is basically a proof of concept. I have a simple database behind it and I am just trying to get it working so that I can view, create, update and delete items. Right now I only have view and update working. I'll tackle create later. For now I can't figure out why the delete doesn't work. Almost everything I have found so far tells me that I need to disable the WebDAV module. I did that and then I got PUT to work. But I can not get DELETE to work. Whenever I attempt to call DELETE through my service I get the following error:

The remote server returned an unexpected response: (405) Method Not Allowed.

So it seems like somewhere on my server it is not allowing the DELETE verb. But for the life of me I can not figure it out. I already checked the Handler Mappings and the handler allows all verbs for the .SVC extension. I have disabled WebDAV. I'm not really sure where else to look. I am using IIS 7.5 on Windows Server 2008 R2.

(I can provide code if it would help at all)

Thanks, Corey

like image 871
Corey Burnett Avatar asked Dec 10 '10 21:12

Corey Burnett


People also ask

How do I fix the 405 method not allowed error on IIS?

If you don't need to use WebDAV, then the easiest and the best way to fix "405 method not allowed" issue is to remove WebDAV from your system. You can easily get this done in "Turn Windows Features On or Off" simply un-ticking the checkbox.

What causes HTTP 405 error?

The HyperText Transfer Protocol (HTTP) 405 Method Not Allowed response status code indicates that the server knows the request method, but the target resource doesn't support this method. The server must generate an Allow header field in a 405 status code response.


1 Answers

In case anyone having the same issue.

Here is another way you can try.

in web.config

<system.webServer>     <modules>       <remove name="WebDAVModule" />     </modules>     <handlers>       <remove name="WebDAV" />      </handlers> </system.webServer> 
like image 110
maxisam Avatar answered Sep 25 '22 02:09

maxisam