选项预检请求未到达IIS托管服务

编程入门 行业动态 更新时间:2024-10-28 00:27:20
本文介绍了选项预检请求未到达IIS托管服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个localhost网站和一个IIS(7.5)托管的WCF服务实现如下,附带Visual Studio调试器。每当我向我的服务提出CORS请求时,我都会得到以下404响应,以及标准的ASP.Net错误页面:

I've got a localhost website and an IIS(7.5) hosted WCF service implemented like this with a Visual Studio debugger attached. Whenever I make a CORS request to my service I'm getting the following 404 response, along with the standard ASP.Net error page:

OPTIONS 192.168.200.44/api/values HTTP/1.1 Host: 192.168.200.44 User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-gb,en;q=0.5 Accept-Encoding: gzip, deflate DNT: 1 Origin: localhost:51946 Access-Control-Request-Method: POST Access-Control-Request-Headers: content-type Connection: keep-alive Pragma: no-cache Cache-Control: no-cache Response >> HTTP/1.1 404 Not Found Content-Type: text/html Server: Microsoft-IIS/7.5 X-Powered-By: ASP.NET Date: Thu, 26 Sep 2013 09:38:49 GMT Content-Length: 1245

最初我收到错误的200条消息,这些消息没有触及我的WCF应用程序的大量断点,所以它本身就是由IIS本身处理的。然后我按照这个和这个 SO发布并从网站上删除OPTIONSVerbHandler,并在IIS管理器UI中添加OPTIONS,PUT,POST& DELETE作为允许的HTTP谓词(而不是web.conf),它让我进入了我的404消息。我查看了WebDav,这是一个突出显示的问题,但我没有禁用/删除它因为我不知道如何但已经读过它只影响PUT& DELETE操作,因为我的POST操作是也失败了。

Originally I was receiving erroneous 200 messages which didn't touch my WCF applictions numerous breakpoints, so it was being handled by IIS itself. I then followed this and this SO posts and removed the OPTIONSVerbHandler from the site and add "OPTIONS, PUT, POST & DELETE" as allowed HTTP verbs in the IIS manager UI (rather then web.conf), which progressed me to my 404 message. I've looked into WebDav which is highlighted as a problem but I haven't disabled/removed it because I don't know how but have read that it only affects "PUT & DELETE" operations where as my "POST" ops are also failing.

GET请求按预期工作,因此服务肯定存在/在IIS中运行,只是选项预检未到达我的服务。

GET requests work as expected so the service definitely exists/works in IIS, just the Options preflight isn't reaching my service.

TY

推荐答案

在IIS GUI上的Handler Mappings中,我不得不恢复默认值以取回 OPTIONSVerbHandler 我之前已删除,一旦完成,我将其编辑为 IsapiModule 而不是 ProtocolSupportModule ,您还需要设置可执行文件%windir%\ Microsoft.NET \Framework\v4.0.30319\aspnet_isapi.dll。除了GET请求之外,这还允许我发出POST请求。

In Handler Mappings on the IIS GUI, I had to restore defaults to get back the OPTIONSVerbHandler I'd previously deleted, once done I edited it to be an IsapiModule rather than a ProtocolSupportModule, you also need to set an executable "%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll". This allowed me to make POST requests in addition to GET requests.

PUT和DELETE仍在报告404,直到我重新启用OPTIONSVerbHandler,然后他们开始报告200(OK)虽然我在附加调试器时看不到它们触摸我的Web服务。

PUT and DELETE were still reporting 404 until I re-enabled the OPTIONSVerbHandler, then they began reporting 200 (OK), though I couldn't see them touching my web services when I attached a debugger.

然后有3个模块称为ExtensionlessUrlHandler- *,两个模块为32 / 64位和一个用于集成,我只改变了32/64位变体(在经典的应用程序池上运行),这对我来说很有用,但是对于任何使用集成应用程序池的人来说,这里可能需要进行一些实验。

There are then 3 modules called "ExtensionlessUrlHandler-*", two for 32/64bit and one for Integrated, I only changed the 32/64bit variants (running on a classic app pool) which worked for me, but for anyone using an integrated app pool some experimentation may be needed here.

无论如何我编辑了32 / 64bit变种,在动词选项卡上的请求限制按钮下我添加了PUT,DELETE,因此它显示为GET,HEAD,POST,DEBUG,PUT,DELETE我的CORS就绪服务中的所有内容都正常工作

Anyway I edited the 32/64bit variants, under the "Request Restrictions" button on the Verbs tab I added "PUT,DELETE" so it read "GET,HEAD,POST,DEBUG,PUT,DELETE" and everything in my CORS ready service is working

更多推荐

选项预检请求未到达IIS托管服务

本文发布于:2023-10-09 16:40:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476224.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项   托管服务   IIS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!