我正在构建的API在Visual Studio中的IIS Express中以及在与实时服务器使用相同IIS的测试服务器上运行。在IIS Express和测试服务器上,API都可以正常工作,但是当我们将其放在实时服务器上时,它会不断返回404响应。
到目前为止,我找到了本文:在IIS Express中解析404,并在本文中找到了解释:在IIS 7中进行请求过滤
据我所知,所有设置都是dafault,但是除了动词外,我还需要检查错误吗?
编辑:看起来它与web.config中的设置有关。托管管道模式设置为集成(经典模式也会导致此问题),并添加了:<system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer>
source。现在api返回了http 500错误,但这是我必须在代码中修复的问题。
向谷歌询问年龄后,我找到了这个网站。
在页面末尾,我必须将svc-Integrated-4.0路径设置为"*"
而不是默认路径,"*.svc"
这为我解决了这个问题!
编辑@Scott H Web.config添加的代码:
<configuration>
<system.webServer>
<handlers>
<remove name="svc-Integrated-4.0" />
<add name="svc-Integrated-4.0" path="*" verb="*" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
</configuration>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句