为什么 HTTP DELETE 动词返回 405 错误 - 在 IIS 7.5 上运行的 RESTful WCF 服务不允许使用该方法? [英] Why does HTTP DELETE verb return 405 error - method not allowed for my RESTful WCF service running on IIS 7.5?

查看:40
本文介绍了为什么 HTTP DELETE 动词返回 405 错误 - 在 IIS 7.5 上运行的 RESTful WCF 服务不允许使用该方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以对此有所了解吗?我觉得我今天浪费了一整天的时间在互联网上寻找有关如何执行此操作的任何信息.我创建了一个非常简单的 WCF RESTful 服务.它基本上是一个概念证明.我有一个简单的数据库,我只是想让它工作,以便我可以查看、创建、更新和删除项目.现在我只有查看和更新​​工作.稍后我将解决创建问题.现在我无法弄清楚为什么删除不起作用.到目前为止,我发现的几乎所有内容都告诉我需要禁用 WebDAV 模块.我做到了,然后我让 PUT 工作.但我无法让 DELETE 工作.每当我尝试通过我的服务调用 DELETE 时,我都会收到以下错误:

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:

远程服务器返回意外响应:(405) Method Not Allowed.

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

所以看起来我的服务器上的某个地方不允许 DELETE 动词.但对于我的生活,我无法弄清楚.我已经检查了处理程序映射,处理程序允许 .SVC 扩展名的所有动词.我已禁用 WebDAV.我不太确定还能在哪里看.我在 Windows Server 2008 R2 上使用 IIS 7.5.

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)

谢谢,科里

推荐答案

我花了很多时间试图弄清楚为什么我在使用 DELETE 动词时总是收到 405 Method Not Allowed.我读到的所有内容都说要从 IIS 卸载 WebDAV,但这似乎破坏了 IIS,因为所有站点都给出了 503 错误.我重新安装了它,然后在 IIS 中寻找一些设置.

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.

事实证明,WebDAV 是问题所在,它在 IIS 功能页面上有一个名为WebDAV Authoring"的节点.点击后,您可以点击WebDAV 设置... 以获取属性页面.在请求过滤行为部分,将允许动词过滤设置为似乎对我有用(YMMV).

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.

这篇关于为什么 HTTP DELETE 动词返回 405 错误 - 在 IIS 7.5 上运行的 RESTful WCF 服务不允许使用该方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆