无扩展 REST WCF 服务为 PUT 方法返回 http 405
我有一个在 VS2008 (3.5) 编写的 IIS6 下本地运行的 WCF REST 服务。
svc 文件的 asp.net ISAPI 映射配置为接受所有动词 我启用了通配符脚本映射,以允许无扩展名的 URI 通过 url 重写来使用该服务。
因此,使用指定的 .svc 文件运行对其余服务的 PUT 可以正常工作。 对省略的 svc 执行相同操作会返回 405。
即
http://thehost/therestmethod = 405 http://thehost/theservice.svc/therestmethod = 200
所有 url 写入版本均以 PUT 为参数唯一的例外!当尝试在无扩展版本上进行 PUT 时,我点击了 url 重写,但之后出现错误,所以我知道重写成功了。
我尝试过使用 WCF 跟踪,但这不会记录错误。好像还没有到这个地步?!?!
I have a WCF REST service running locally under IIS6 written in VS2008 (3.5).
The asp.net ISAPI mapping for the svc file is configured to accept all verbs
I have enabled wildcard script mapping to allow extensionless URI's to work with the service via url rewrite.
So running a PUT to the rest service with the .svc file specified works OK.
Doing the same with the svc omitted returns a 405.
i.e
http://thehost/therestmethod = 405
http://thehost/theservice.svc/therestmethod = 200
All the url written versions work with PUT being the only exception! When attempting the PUT on the extensionless version I hit the url rewrite ok but errors after so I know the rewrite succeeded.
I've tried using WCF tracing but this isn't logging the error. It seems it's not getting that far?!?!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取自此处:
HTTP 动词:虽然大多数防火墙和 Web 客户端都允许 HTTP GET 和 POST 动词,其中一些不支持 PUT、DELETE 和其他动词。要启用此类不受支持的动词的调用,常见做法是在 POST 请求上使用 X-HTTP-Method-Override HTTP 标头来指定您希望调用的方法。 XHttpMethodOverride 示例描述了如何实现此功能。
我想 IIS url 重写/允许动词检查代码中有些东西不太一致。
希望这有帮助。
Taken from here:
HTTP Verbs: While most firewalls and web clients allow for the HTTP GET and POST verbs, some of them do not support PUT, DELETE, and other verbs. To enable the invocation of such unsupported verbs, a common practice is to use the X-HTTP-Method-Override HTTP header on a POST request to specify the method you wish to call. The XHttpMethodOverride sample describes how to implement this functionality.
I imagine something isn't quite aligned in the IIS url re-write / allowed verb checking code.
Hope this helps.