創建了一個 webapi,在郵遞員中一切順利,但是當我在 Angular 7 中創建一個前端應用程序并嘗試登錄時出現錯誤:對預檢請求的響應未通過訪問控制檢查:沒有'Access-Control-Allow-Origin'請求的資源上存在標頭。試圖禁用 cors 以在 chrome 中進行開發,但仍然出現相同的錯誤,將 webapi 配置為允許所有,仍然相同,更改 web 配置以允許預檢方法的選項,仍然相同。(使用 owin) public void Configuration(IAppBuilder app) { var configuration = new HttpConfiguration(); ConfigureOAuth(app); app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); WebApiConfig.Register(configuration); app.UseWebApi(configuration); <modules runAllManagedModulesForAllRequests="true"> <remove name="WebDAVModule" /> </modules> <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> </system.webServer>
1 回答

翻過高山走不出你
TA貢獻1875條經驗 獲得超3個贊
可能您的 IIS 不支持 OPTION 動詞調用 https://support.deskpro.com/en/kb/articles/configuring-http-verbs-on-windows-iis
- 1 回答
- 0 關注
- 677 瀏覽
添加回答
舉報
0/150
提交
取消