我编写了一个使用ASP.NET MVC Web API的站点,一切都运行良好,直到我把它放在登台服务器上.该站点在我的本地计算机和开发Web服务器上运行良好.开发和登台服务器都是Windows Server 2008 R2.
问题是:基本上网站工作,但有一些API调用使用HTTP PUT方法.这些失败在分段返回404,但在其他地方工作正常.
我遇到并修复的第一个问题是请求过滤.但仍然得到404.
我在IIS中打开了跟踪并遇到以下问题.
168. -MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName IIS Web Core
Notification 16
HttpStatus 404
HttpReason Not Found
HttpSubStatus 0
ErrorCode 2147942402
ConfigExceptionInfo
Notification MAP_REQUEST_HANDLER
ErrorCode The system cannot find the file specified. (0x80070002)
Run Code Online (Sandbox Code Playgroud)
开发和分期时的配置是相同的,事实上整个站点是直接副本.
为什么GET和POST工作,而不是PUT?
在我的Web API项目中,我无法执行HTTP PUT我的资源.我已经阅读了一些 关于这个问题的类似 问题 , 并且我遵循了建议的建议.
首先,我在我的机器上完全卸载了WebDAV(Windows 7 64位),然后重新启动了我的机器.
其次,WebDAV处理程序在我的指定中被删除,web.config并且HTTP PUT动词被指定为允许无扩展URL处理程序.
<modules runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule"/>
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="WebDAV"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0"
path="*."
verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS"
type="System.Web.Handlers.TransferRequestHandler"
resourceType="Unspecified"
requireAccess="Script"
preCondition="integratedMode,runtimeVersionv4.0" />
<add name="AttributeRouting" path="routes.axd" verb="*" type="AttributeRouting.Web.Logging.LogRoutesHandler, AttributeRouting.Web" />
</handlers>
Run Code Online (Sandbox Code Playgroud)
我甚至尝试添加ISAPI无扩展URL处理程序(32位和64位)并将我的应用程序从集成管道应用程序池更改为经典应用程序池.
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"
path="*."
verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS"
modules="IsapiModule"
scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"
preCondition="classicMode,runtimeVersionv4.0,bitness32"
responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"
path="*."
verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS"
modules="IsapiModule"
scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll"
preCondition="classicMode,runtimeVersionv4.0,bitness64"
responseBufferLimit="0" />
Run Code Online (Sandbox Code Playgroud)
我目前正在使用Thinktecture IdentityModel来启用跨源资源共享(CORS)支持.为了我的理智,我已经选择了启用一切以确保HTTP …