diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcOptions.cs index 55d5512c6a..d9af39476d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcOptions.cs @@ -1,4 +1,6 @@ -using Volo.Abp.AspNetCore.Mvc.Conventions; +using System; +using System.Collections.Generic; +using Volo.Abp.AspNetCore.Mvc.Conventions; namespace Volo.Abp.AspNetCore.Mvc { @@ -8,9 +10,12 @@ namespace Volo.Abp.AspNetCore.Mvc public AbpConventionalControllerOptions ConventionalControllers { get; } + public HashSet IgnoredControllersOnModelExclusion { get; } + public AbpAspNetCoreMvcOptions() { ConventionalControllers = new AbpConventionalControllerOptions(); + IgnoredControllersOnModelExclusion = new HashSet(); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs index 3198e73e45..4d1490ec40 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs @@ -77,10 +77,21 @@ namespace Volo.Abp.AspNetCore.Mvc.Conventions foreach (var controllerModel in application.Controllers) { + if (!controllerModel.ControllerType.IsDefined(typeof(ExposeServicesAttribute), false)) + { + continue; + } + + if (Options.IgnoredControllersOnModelExclusion.Contains(controllerModel.ControllerType)) + { + continue; + } + var baseControllerTypes = controllerModel.ControllerType .GetBaseClasses(typeof(Controller), includeObject: false) .Where(t => !t.IsAbstract) .ToArray(); + if (baseControllerTypes.Length > 0) { derivedControllerModels.Add(controllerModel);