Nei*_*ski 30 asp.net iis asp.net-core asp.net-core-webapi
我们有一个ASP.NET Core 2.0网站,它还提供了一些用于UI增强目的的简单Web API方法.
在IIS Express下本地运行时,Web API调用按预期工作,但是当我们部署到IIS 8.5生产Web服务器时,在发出HTTP 和请求时会出现以下错误...DELETEPUT
405 Method Not Allowed
Run Code Online (Sandbox Code Playgroud)
经过一些网络搜索后,我们发现了几篇建议删除IIS WebDAV模块的帖子.我们在IIS中禁用了它(它是我们的服务器),我们也尝试了以下方法:
Allow verb filtering = FalseaspNetCore,WebDAV和ExtensionlessUrlHandler-Integrated-4.0上述步骤都没有解决我们的问题.
任何建议/方向将不胜感激.
Nei*_*ski 42
经过数小时的研究和反复试验,修复似乎非常简单.将Web.config文件添加到.NET Core 2.0应用程序:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- To customize the asp.net core module uncomment and edit the following section.
For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="aspNetCore" />
<remove name="WebDAV" />
<!-- I removed the following handlers too, but these
can probably be ignored for most installations -->
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="aspNetCore"
path="*"
verb="*"
modules="AspNetCoreModule"
resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%"
arguments="%LAUNCHER_ARGS%"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
Man*_*ves 35
这对我有用(netcore 2.0)
<system.webServer>
<modules runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule" />
</modules>
</system.webServer>Run Code Online (Sandbox Code Playgroud)
在此处找到:https://www.ryadel.com/en/error-405-methods-not-allowed-asp-net-core-put-delete-requests/
就我而言,我收到 .Net 5 Web API PUT 和 DELETE 调用的 405 错误。我尝试了多种解决方案,例如删除 WebDAV(打开或关闭 Windows 功能 -> IIS -> 万维网服务 -> 通用 HTTP 功能 -> WebDAV 发布)不起作用,在“处理程序映射”中编辑 WebDAV 条目搞乱了应用程序。
解决方案
在 IIS 中,选择应用程序
虽然删除 WebDAV 可能会解决您的问题,但您可能想知道(就像我一样),WebDAV 是什么以及它的用途是什么?
我发现这个页面有助于解释它:
https://www.cloudwards.net/what-is-webdav/
小智 7
将以下行添加到您的 web.config 文件中。就可以了。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,PUT,DELETE,DEBUG" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Ftms.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
要完全阻止启用 WebDav,请从ApplicationHost.config 中删除以下条目:
<add name="WebDAVModule" />
Run Code Online (Sandbox Code Playgroud)
该条目位于模块部分。
配置的确切位置:
C:\Windows\System32\inetsrv\config\applicationHost.config
这在 .Net Core 2.1 中对我很有效
requireAccess="None"就我而言,我在添加到aspNetCore处理程序后解决了问题
像这样 :
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" requireAccess="None" />
Run Code Online (Sandbox Code Playgroud)
小智 5
从 IIS 服务器中删除 WebDAV 发布。它属于 Internet Information 服务 -> Common Http Features
https://ignas.me/tech/405-method-not-allowed-iis/
| 归档时间: |
|
| 查看次数: |
22919 次 |
| 最近记录: |