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

后端 未结 4 908
时光取名叫无心
时光取名叫无心 2021-02-05 02:22

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

相关标签:
4条回答
  • 2021-02-05 02:49

    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

    0 讨论(0)
  • 2021-02-05 02:53

    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

    0 讨论(0)
  • 2021-02-05 02:54

    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.

    0 讨论(0)
  • 2021-02-05 03:01

    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>
    
    0 讨论(0)
提交回复
热议问题