2017-08-04 96 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")]至少測試

相關問題