试图通过Angular http post方法来击中WEB API,但无法击中网页api和catch块也不会引发任何错误。我也启用了跨国策略。 当我在浏览器中粘贴web api url时,它会触发该方法,但不会通过角度http发布功能。无法打网络api。甚至无法获得错误
下面是代码组件代码
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
this._http.post(this._commonUrl, filter, options)
.map(response => response.json())
.catch(this.handleError);
private handleError(error: Response) {
console.error(error);
return Observable.throw(error.json().error || 'Server error');
}
控制器代码
[RoutePrefix("api/common")]
public class ProductController : ApiController
{
public ProductController()
{
}
[Route("initialize")]
[HttpPost]
public HttpResponseMessage SearchLazada(Filter filter)
{
try
{
}
}
}
的[角2 HTTP GET得不到]可能的复制(https://stackoverflow.com/questions/ 41381200/angular-2-http-get-not-getting) – Alex