我正在尝试将http.delete请求调用到我的服务器。
deleteStudent(id){
let body = JSON.stringify({"Id":id});
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({headers: headers});
this.http.delete('http://localhost:10090/app/Test/'+id,{headers:headers}).subscribe((res) => {
});
这是我在C#web API中的服务器代码
[HttpDelete]
[Route("app/Test/{id}")]
public void deleteByid(int id) {
}
错误代码
OPTIONS http://localhost:10090/app/Test/2 405 (Method Not Allowed)
XMLHttpRequest cannot load http://localhost:10090/app/Test/2. Response for preflight has invalid HTTP status code 405
Response {_body: ProgressEvent, status: 0, ok: false, statusText: "", headers: Headers, …}