从 angular 调用 post 方法时遇到问题
Facing issue while calling post method from angular
我正在从 angular 调用 post web api 方法,但出现以下错误:
"Failed to load : Response for preflight has invalid HTTP status code 404"
我已启用允许跨源请求。
见下面的代码:
return this._http.post("http://localhost:64575/api/Rules",
{
currentPage: 1,
pageSize: 10,
sortColumn: 'id',
sortDirection: 'asc'
}, requestOptions)
.map(res=>res.json());
每当您发出 Post 请求时,都会对服务器
进行 2 次调用
- 使用"Options"请求方式调用
- 实际 post 通话
现在您需要处理对 API 实现的 "Options" 调用
参考文献 link:
我正在从 angular 调用 post web api 方法,但出现以下错误: "Failed to load : Response for preflight has invalid HTTP status code 404" 我已启用允许跨源请求。
见下面的代码:
return this._http.post("http://localhost:64575/api/Rules",
{
currentPage: 1,
pageSize: 10,
sortColumn: 'id',
sortDirection: 'asc'
}, requestOptions)
.map(res=>res.json());
每当您发出 Post 请求时,都会对服务器
进行 2 次调用- 使用"Options"请求方式调用
- 实际 post 通话
现在您需要处理对 API 实现的 "Options" 调用
参考文献 link: