Http 动词属性不起作用
Http Verb Attribute Not Working
我已经用 Http 动词属性装饰了我的服务接口,但是没有用。
每个方法都被视为 Post 动词。
我正在使用 AspNetCore 1.1 和 Abp 包 2.3.0
public interface ISettlementAppService : IApplicationService
{
Task<PagedResultDto<SettlementListDto>> GetPaged(GetSettlementInput input);
[HttpDelete]
Task Cancel(EntityDto<string> input);
}
对于 AspNet Core,将这些属性添加到应用程序服务 class,而不是接口。因为它们由 AspNet Core MVC(而不是 ABP)处理,并且它不知道接口。
来自文档 (https://aspnetboilerplate.com/Pages/Documents/AspNet-Core#controllers):
Note: Previously, dynamic web api system was requiring to create service interfaces for application services. But this is not required for ASP.NET Core integration. Also, MVC attributes should be added to the service classes, even you have interfaces.
这样做;
public class SettlementAppService : ISettlementAppService
{
[HttpDelete]
Task Cancel(EntityDto<string> input){
//...
}
}
我已经用 Http 动词属性装饰了我的服务接口,但是没有用。 每个方法都被视为 Post 动词。
我正在使用 AspNetCore 1.1 和 Abp 包 2.3.0
public interface ISettlementAppService : IApplicationService
{
Task<PagedResultDto<SettlementListDto>> GetPaged(GetSettlementInput input);
[HttpDelete]
Task Cancel(EntityDto<string> input);
}
对于 AspNet Core,将这些属性添加到应用程序服务 class,而不是接口。因为它们由 AspNet Core MVC(而不是 ABP)处理,并且它不知道接口。
来自文档 (https://aspnetboilerplate.com/Pages/Documents/AspNet-Core#controllers):
Note: Previously, dynamic web api system was requiring to create service interfaces for application services. But this is not required for ASP.NET Core integration. Also, MVC attributes should be added to the service classes, even you have interfaces.
这样做;
public class SettlementAppService : ISettlementAppService
{
[HttpDelete]
Task Cancel(EntityDto<string> input){
//...
}
}