1. 程式人生 > 實用技巧 >Asp.NETCore 部署IIS配置了允許跨域但還是不支援 PUT , POST請求

Asp.NETCore 部署IIS配置了允許跨域但還是不支援 PUT , POST請求

允許跨域配置:

我配置的是允許指定域名,如果允許所有域名 使用AllowAnyOrigin() 就可以了。

部署到IIS 後發現Get請求正常,Put請求 提示跨域

找到web.config檔案增加

<remove name="WebDAVModule" />
<remove name="WebDAV" />
重新啟動網址即可

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <configuration>
 3   <system.webServer>
 4     <modules 
runAllManagedModulesForAllRequests="true" runManagedModulesForWebDavRequests="true"> 5 <remove name="WebDAVModule" /> 6 </modules> 7 <handlers> 8 <remove name="WebDAV" /> 9 <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2"
resourceType="Unspecified" /> 10 </handlers> 11 <aspNetCore processPath="C:\Program Files\dotnet\dotnet.exe" arguments=".\TexHong_EMWX.Web.Host.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00">
12 <environmentVariables /> 13 </aspNetCore> 14 <httpProtocol> 15 <customHeaders> 16 <remove name="X-Powered-By" /> 17 </customHeaders> 18 </httpProtocol> 19 </system.webServer> 20 </configuration>