0
我下載了ASP Boilerplate模板,並試圖禁用某些動態WebAPI的創建。我閱讀https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API文檔,但我無法找到在模板中禁用此功能的位置。我正在使用NET Core + Angular4模板。禁用某些服務的動態web api
我下載了ASP Boilerplate模板,並試圖禁用某些動態WebAPI的創建。我閱讀https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API文檔,但我無法找到在模板中禁用此功能的位置。我正在使用NET Core + Angular4模板。禁用某些服務的動態web api
您可以使用屬性[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();
非常感謝,工作! –