net core在IIS上部署出现Method not found
1、为什么会出现Method not found
说明地址:https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Status/405
这里顺带也说一下跨域的问题,详情看下一官方文档:https://docs.microsoft.com/zh-cn/aspnet/core/security/cors?view=aspnetcore-2.2
2、解决办法
由于描述了 GET、HEAD 或 POST浏览器是可以跳过预检请求的,接口中涉及到了PUT、DELETE时就会出现Method not found
这时候由于netcore
默认使用的是AspNetCoreModuleV2
模块,需要使用AspNetCoreModule
模块,打开web.config
文件移除掉WebDAVModule
模块
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers accessPolicy="Read, Script">
<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" requireAccess="Script" />
</handlers>