-1
我有一個Angular2應用程序和ASP.NET網頁API 2 CORS全局啓用: 到預檢要求CORS響應當端點需要參數
,如果我離開參數爲空,我沒有問題,從我的前端調用它,但如果我離開它,要求loginmodel,我得到f ollowing: 和要求:
誰能告訴這怎麼可能呢?至少如何解決它。
我有一個Angular2應用程序和ASP.NET網頁API 2 CORS全局啓用: 到預檢要求CORS響應當端點需要參數
,如果我離開參數爲空,我沒有問題,從我的前端調用它,但如果我離開它,要求loginmodel,我得到f ollowing: 和要求:
誰能告訴這怎麼可能呢?至少如何解決它。
我無法解釋這一點,但它的工作。 我刪除:
var cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);
從我WebApiConfig,反而增加了以下到我的web.config:
<system.webServer>
<httpProtocol>
<customHeaders>
<!-- This enables your CORS Requests to be accepted. -->
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Credentials" value="true" />
<add name="Access-Control-Allow-Methods" value="GET, POST, OPTIONS" />
</customHeaders>
</httpProtocol>
我之所以沒有從beginnig做到這一點的是,我的Web API 2沒有system.webserver,它有一個system.web,我不知道我可以兼得。如果有人能夠對此有所瞭解,請做