0
我說這對我的API部門conrtoller當我運行它的網站上說,它沒有找到,我不熟悉C#與做任何幫助..HTTP DELETE找不到然而
[HttpDelete]
public async Task<IHttpActionResult> Remove([FromBody] Department tObj, [FromUri]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/Remove'.",
"MessageDetail": "No action was found on the controller 'Department' that matches the request."
}
請求負載
{Key: 18, Users: null, Projects: null, Status: null, Code: "ppp", Name: "lll", IsActive: true,…}
Code:"ppp"
IsActive:true
Key:18
Name:"lll"
Projects:null
State:2
Status:null
StatusMessage:null
Users:null
這是前端(REACTJS)
delete(form) {
debugger
form.State = 2;
let id = form.Key;
this.props.deleter('department/Remove', form);}
然後繼續這個AJAX
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)));
}
}
林不知道爲什麼它不讀控制器,因爲除了刪除其他控制器的工作..
@LAGIM是否正常工作? –