2017-08-11 36 views

回答

1

您可以使用屬性[RemoteService]禁用創建應用程序服務的動態Web API。您也可以在應用程序服務的方法上使用此屬性。

[RemoteService(false)] 
public interface IRoleAppService : IAsyncCrudAppService<RoleDto, int, PagedResultRequestDto, CreateRoleDto, RoleDto> 
{ 
     Task<ListResultDto<PermissionDto>> GetAllPermissions(); 
} 

https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API#enabledisable


儘管[RemoteService]是禁用它的最簡單的方法,你可以用下面的代碼進行高級操作。

Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder 
    .ForAll<IApplicationService>(Assembly.GetExecutingAssembly(), "app") 
    .ForMethods(builder => 
    { 
     if (builder.Method.IsDefined(typeof(MyIgnoreApiAttribute))) 
     { 
      builder.DontCreate = true; 
     } 
    }) 
    .Build(); 
+0

非常感謝,工作! –