PutAsync不工作 - web Api2和MVC4

时间:2016-03-16 08:13:53

标签: asp.net-mvc-4 asp.net-web-api

我们有一个运行MVC4前端的应用程序正在使用web api2 rest PUT。它在IIS 8.5和Windows Server 2012中运行

我正在使用PutAsync来更新某些数据,但是获得了405 - 不允许的方法。我环顾四周,发现有些人遇到了这个问题,并且通过在API的web.config中使用一些或其他技术解决了这个问题。

我在网络API配置中试过这个,它对我有用。

<modules runAllManagedModulesForAllRequests="true">
   <remove name="WebDAVModule" />
</modules>

<handlers>
 <remove name="WebDAV" />
</handlers>

但我不确定为什么。我没有为我的网站定义任何webdav创作规则。有人可以帮我理解为什么这对我有用吗?

此外,为API设置runAllManagedModulesForAllRequests = true是否存在缺点?

1 个答案:

答案 0 :(得分:0)

可以从machine.config开始配置。有关详细信息,请Configuration Inheritance in this page。它也可以从包含文件夹中的任何其他web.config继承。

runAllManagedModulesForAllRequests表示对包含此web.config的文件夹(和子文件夹)所做的任何请求都将被处理到已注册的模块。例如,它将尝试处理对看起来不像Web API操作的请求。请看这个:<modules runAllManagedModulesForAllRequests="true" /> Meaning