【发布时间】:2018-12-29 14:27:55
【问题描述】:
我使用 Ionic 构建应用程序,我想发布我准备测试的 API API使用邮递员它可以正常工作 但是当我使用 Ionic 时遇到错误 405 Method not allowed 这是请求的响应:
{"Message":"请求的资源不支持HTTP方法'OPTIONS'。"}
我在邮递员上获得了状态 200,但使用 ionic 获得了 405
邮递员:
这是我的代码:
var auth = 'bearer ' + Token;[enter image description here][1]
let headers = new Headers({
'Content-Type': 'application/json',
'withCredentials': 'true',
'Authorization': auth
});
return this.http.post('http://abdalrahmannada-001-site1.htempurl.com/api/Rabbit/AddRabbit', { headers: headers })
.map(response => response);
【问题讨论】:
-
你的 api 是否启用了 cors?
-
不,我该怎么办?
-
我将此代码添加到网络配置
-
-
它的后端问题。您需要启用 cors 。
标签: asp.net-mvc ionic-framework asp.net-web-api ionic3 postman