【发布时间】:2019-03-03 12:12:21
【问题描述】:
我已经使用 ASP.NET Web API 构建了一些 API 端点。当我尝试执行 PUT 或 DELETE 请求时,得到 405 Method Not Allowed 错误。但它对 GET 和 POST 请求运行良好。
有趣的是,当我在本地 IIS 中托管项目时,PUT 和 DELETE 运行良好。它只会在 DEV 服务器中抛出 405 错误。
在我的 web.config 中:
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
</system.web>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
</system.webServer>
我在这里缺少什么?提前致谢。
【问题讨论】:
-
是否在
<modules>和<remove name="WebDAV" />内添加<remove name="WebDAVModule"/><handlers>有帮助? -
是的,它解决了我的问题。你能详细说明答案吗?谢谢
-
你可以参考我的回答here