試圖通過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