2017-08-04 106 views
0

我说这个。但是我的API部门conrtoller当我运行它的网站上说,它没有找到,我不熟悉C#与做任何帮助..没有HTTP资源被发现

[HttpDelete] 
      [AcceptVerbs("Delete")] 
      [ResponseType(typeof(Department))] 
      public override async Task<IHttpActionResult> Delete(Department tObj, bool? tagAsDeleteOnly) 
      { 
       _bll.Delete(tObj, tagAsDeleteOnly ?? true); 

       var result = await _bll.Save(); 

       return Ok(new WebResult 
       { 
        Data = tObj, 
        Total = (int)result, 
        Result = result > 0 
       }); 
      } 

的错误说

{ 
    "Message": "No HTTP resource was found that matches the request URI 'http://localhost:8933/api/Department/Delete'.", 
    "MessageDetail": "No action was found on the controller 'Department' that matches the request." 
} 

这是我传递 what i pass picture

这是我在我的前端

代码
delete(form) { 
     debugger 
     form.State = 2; 
     let id = form.Key; 
     //delete form.Key; 
     this.props.deleter('department/Delete', form); 
} 

,然后继续

export const deleter = (url, params) => { 
    return(dispatch, getState, api) => { 
     api += 'api/'; 
     return fetch(`${api}${url}`, { 
      method: 'DELETE', 
      headers: { 
       'Content-Type': 'application/json' 
      }, 
      body: JSON.stringify(params) 
     }) 
     .then(response => response.json()) 
     .then(result => dispatch(departmentResult(result, types.DELETER))); 
    } 
} 
+0

由[HttpDelete]属性指定的是您确实发送删除请求验证这一点? –

+0

怎么办你通过'部门'对象? –

+0

我不知道你的意思是,但..即时通讯发送项目'api/Department/Delete'' @AlanBuchanan – LAGIM

回答

1

虽然身体没有明确的DELETE请求禁止的,它经常服务器将忽略。

试着改变你的行动

public override async Task<IHttpActionResult> Delete(string departmentCode, bool? tagAsDeleteOnly) 

和使用参数,即添加构建您的网址?departmentCode=params.Code

另外值得一检查this post发现了一个错误的位置自动执行请求的图书馆翻了DELETEPOST如果有一个消息主体在场。

您可以轻松地通过使用开发工具在浏览器(或更改属性[AcceptVerbs("Post")]至少测试

相关问题