2017-09-13 17 views
0

我用Http Verb Attributes裝飾了我的服務接口,但無法正常工作。 每種方法都被視爲Post動詞。Http Verb屬性不起作用

我使用AspNetCore 1.1和ABP包2.3.0

public interface ISettlementAppService : IApplicationService 
{ 
    Task<PagedResultDto<SettlementListDto>> GetPaged(GetSettlementInput input); 

    [HttpDelete] 
    Task Cancel(EntityDto<string> input); 
} 
+0

你的意思是你在裝修控制器的動作與HTTPGET,HttpPut或HttpDelete和所有的人都仍被視爲HttpPost?**你試過命名你的行動爲GetMethod,PutMethod等?** 請將您的代碼放在您的問題中 –

+0

我沒有使用控制器。我正在使用應用程序服務和動態webapi。根據這個文檔[https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API](https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API),它應該只能通過裝飾界面方法。 但我弄清楚,只有具體的類方法裝飾時纔有效。也許這應該是bug,我不知道。 –

回答

1

這樣做;

public class SettlementAppService : ISettlementAppService 
{ 

    [HttpDelete] 
    Task Cancel(EntityDto<string> input){ 
     //... 
    } 
} 
2

對於ASPNET核心,這些屬性添加到應用程序的服務類,而不是接口。因爲它們由AspNet Core MVC(不是由ABP)處理,並且它不知道接口。

從文檔(https://aspnetboilerplate.com/Pages/Documents/AspNet-Core#controllers):

注:此前,動態網頁API系統需要創建應用程序服務的服務接口。但是,這對於ASP.NET Core集成不是必需的。另外,即使你有接口,MVC屬性也應該添加到服務類中。