ASP.NET Web API 仅在某些服务器上为 PUT 返回 404 [英] ASP.NET Web API returns 404 for PUT only on some servers

查看:26
本文介绍了ASP.NET Web API 仅在某些服务器上为 PUT 返回 404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个使用 ASP.NET MVC Web API 的站点,在我将它放到临时服务器之前,一切都运行良好.该站点在我的本地机器和开发网络服务器上运行良好.开发服务器和临时服务器都是 Windows Server 2008 R2.

I have written a site that uses ASP.NET MVC Web API and everything is working nicely until I put it on the staging server. The site works fine on my local machine and on the dev web server. Both dev and staging servers are Windows Server 2008 R2.

问题是这样的:网站基本上可以运行,但是有一些 API 调用使用了 HTTP PUT 方法.这些在登台返回 404 时失败,但在其他地方工作正常.

The problem is this: basically the site works, but there are some API calls that use the HTTP PUT method. These fail on staging returning a 404, but work fine elsewhere.

我遇到并解决的第一个问题是请求过滤.但仍然得到 404.

The first problem that I came across and fixed was in Request Filtering. But still getting the 404.

我在 IIS 中打开了跟踪并遇到以下问题.

I have turned on tracing in IIS and get the following problem.

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) 

dev 和 staging 的配置是一样的,事实上整个站点都是直接复制的.

The configs are the same on dev and staging, matter of fact the whole site is a direct copy.

为什么 GET 和 POST 可以工作,而 PUT 不行?

Why would the GETs and POSTs work, but not the PUTs?

推荐答案

那些 IIS 服务器上安装了 web-dav 模块,我敢打赌它是不需要的,因为安装的人勾选了所有框.

Those IIS servers have web-dav module installed on them and i bet it is not needed and it was installed because the person installing ticked all boxes.

只需从 iis 中删除 web-dav.

Just remove web-dav from iis.

或者使用 web.config 删除 web dav 模块:

Alternatively use web.config to remove web dav module:

<system.webServer>
    <modules>
        <remove name="WebDAVModule" />
    </modules>
    ...

这篇关于ASP.NET Web API 仅在某些服务器上为 PUT 返回 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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