WebAPI 删除不起作用 - 405 Method Not Allowed [英] WebAPI Delete not working - 405 Method Not Allowed

查看:40
本文介绍了WebAPI 删除不起作用 - 405 Method Not Allowed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您对此提供的任何帮助,因为该网站将于今晚上线!

I appreciate any help on this as the site is supposed to go live tonight!

我有一个带有 Delete 方法的 web api 控制器.该方法在运行 IIS Express (Windows 8) 的本地计算机上运行良好,但一旦我将其部署到实时 IIS 服务器 (Windows Server 2008 R2) 上,它就停止工作并抛出以下错误消息:

I have a web api controller with a Delete method. The method executes fine on my local machine running IIS Express (Windows 8) but as soon as I deployed it to the live IIS server (Windows Server 2008 R2) it stopped working and throws the following error message:

HTTP 错误 405.0 - 不允许的方法由于使用了无效的方法(HTTP Verb),您正在查找的页面无法显示

我在网上四处寻找解决方案,并实施了最合理的解决方案.我的网络配置有以下设置:

I have looked around the web for solutions and I implemented most reasonable ones. My web config has the following settings:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
<handlers>
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
    <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFrameworkv4.0.30319aspnet_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.NETFramework64v4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>

我也尝试过更改 IIS 中的处理程序映射和请求过滤无济于事.请注意,IIS 中的 WebDAV 创作规则似乎已禁用.

I have also tried to change the Handler Mappings and Request Filtering in IIS to no avail. Please note that the WebDAV Authoring Rules in IIS seems to be disabled.

任何想法将不胜感激谢谢.

Any ideas will be greatly appreciated Thanks.

推荐答案

我终于找到了解决方案!如果您遇到同样的问题,请将以下内容添加到您的 web.config

I found the solution eventually! If you come across the same issue, add the following to your web.config

<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
        <remove name="WebDAVModule"/> <!-- ADD THIS -->
    </modules>
    ... rest of settings here

希望能帮到你

这篇关于WebAPI 删除不起作用 - 405 Method Not Allowed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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