我有其他應用程序與Angular2和ASP MVC休息服務器,我有一個通信問題。 當我送東西,我得到這個錯誤:ASP MVC與Angular2的Web api - Http標題訪問控制
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost:4200 ' is therefore not allowed access.
當我將訪問控制允許來源要求,我得到這個錯誤:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost:4200 ' is therefore not allowed access. The response had HTTP status code 404.
這裏是我的代碼:
let headers = new Headers({ 'Access-Control-Allow-Origin': '*' })
this.http.get("http://localhost/App/Users", { withCredentials: true, headers: headers })
.subscribe(response => {
console.log("A");
}, error => {
console.log(error);
});
在web.config中啓用了Windows身份驗證。 問題在哪裏?
你如何啓用網絡API中的Cors? – hasan