用于预检的Angular 2 http.delete -Response具有无效的HTTP状态代码405

时间:2017-09-06 12:00:39

标签: asp.net angular

我正在尝试将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, …}

0 个答案:

没有答案