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

4

37

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

Killoran answered 10/12, 2010 at 21:25 Comment(0)
B
30

I just spent a ton of time trying to figure out why I kept getting 405 Method Not Allowed when using the DELETE verb. Everything I read said to uninstall WebDAV from IIS, but that seemed to break IIS in that all sites gave 503 errors. I reinstalled it, then went about looking in IIS for some setting.

It turns out that WebDAV is the problem, and it has a node on the IIS features page named "WebDAV Authoring". Clicking on that lets you then click on WebDAV Settings... to get the properties page. In the section Request Filtering Behavior, set Allow Verb Filtering to False seemed to do the trick for me (YMMV).

This seemed to be a popular result when googling for a solution, so I thought I'd add to the list of suggested solutions.

Butternut answered 20/2, 2012 at 5:11 Comment(0)
N
81

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>
Nigger answered 27/12, 2012 at 20:19 Comment(6)
Through the IIS GUI, go to Modules and Handler Mappings to remove. Thanks maxisam!Unconventionality
This worked for me even though WebDAV was already configured to allow DELETE and it was also configured with Allow Verb Filtering: false.Itinerary
This was all I had to do to get the PUT and DELETE methods from being 405'ed in my WCF RESTful service. Thank you.Schooner
check for both handlers and modules in your web.config for duplication before adding this snippetGuttapercha
Thanks, this worked for me. I was removing handler but not module. Once removing module deletes worked as expected. Thanks again.Cleanshaven
I spent so much time and could not fix it until I went to iis gui and removed webdav from modules.Felt
B
30

I just spent a ton of time trying to figure out why I kept getting 405 Method Not Allowed when using the DELETE verb. Everything I read said to uninstall WebDAV from IIS, but that seemed to break IIS in that all sites gave 503 errors. I reinstalled it, then went about looking in IIS for some setting.

It turns out that WebDAV is the problem, and it has a node on the IIS features page named "WebDAV Authoring". Clicking on that lets you then click on WebDAV Settings... to get the properties page. In the section Request Filtering Behavior, set Allow Verb Filtering to False seemed to do the trick for me (YMMV).

This seemed to be a popular result when googling for a solution, so I thought I'd add to the list of suggested solutions.

Butternut answered 20/2, 2012 at 5:11 Comment(0)
S
2

Open your website's Handler Mappings in IIS Manager

Edit each handler you want to DELETE with, clicking Request Restrictions, choosing the Verbs tab, then add DELETE to the "One of the following" list or, if appropriate within your concerns, allow all verbs.

You might need to restart your website and/or recompile your code

Sapsago answered 18/10, 2013 at 20:40 Comment(0)
K
0

Well I'm not sure if this is really an answer to my question but it did solve the problem. I simply started a new project in Visual Studio and this time I used the .NET REST Service template that I found online. Then I transferred the old code I had from my previous attempt and used it in the new project. It worked like a charm. All four verbs work correctly now (GET, PUT, POST and DELETE). So it is working now.

Corey

Killoran answered 11/12, 2010 at 22:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.