diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs index 5ceb180d475..1e103d84406 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs @@ -80,7 +80,7 @@ private void AddApiDescriptionToModel( var setting = FindSetting(controllerType); var moduleModel = applicationModel.GetOrAddModule( - GetRootPath(controllerType, setting), + GetRootPath(controllerType, apiDescription.ActionDescriptor, setting), GetRemoteServiceName(controllerType, setting) ); @@ -327,7 +327,9 @@ public string GetMethodParamName(ParameterInfo parameterInfo) return modelNameProvider.Name ?? parameterInfo.Name; } - private static string GetRootPath([NotNull] Type controllerType, + private static string GetRootPath( + [NotNull] Type controllerType, + [NotNull] ActionDescriptor actionDescriptor, [CanBeNull] ConventionalControllerSetting setting) { if (setting != null) @@ -335,7 +337,7 @@ private static string GetRootPath([NotNull] Type controllerType, return setting.RootPath; } - var areaAttr = controllerType.GetCustomAttributes().OfType().FirstOrDefault(); + var areaAttr = controllerType.GetCustomAttributes().OfType().FirstOrDefault() ?? actionDescriptor.EndpointMetadata.OfType().FirstOrDefault(); if (areaAttr != null) { return areaAttr.RouteValue; diff --git a/framework/src/Volo.Abp.Http.Client.Web/Volo/Abp/Http/Client/Web/Conventions/AbpHttpClientProxyServiceConvention.cs b/framework/src/Volo.Abp.Http.Client.Web/Volo/Abp/Http/Client/Web/Conventions/AbpHttpClientProxyServiceConvention.cs index 52ccdabfc5a..656c361062a 100644 --- a/framework/src/Volo.Abp.Http.Client.Web/Volo/Abp/Http/Client/Web/Conventions/AbpHttpClientProxyServiceConvention.cs +++ b/framework/src/Volo.Abp.Http.Client.Web/Volo/Abp/Http/Client/Web/Conventions/AbpHttpClientProxyServiceConvention.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Reflection; using Microsoft.AspNetCore.Mvc; @@ -50,6 +51,15 @@ protected override void ApplyForControllers(ApplicationModel application) { controller.ControllerName = controller.ControllerName.RemovePostFix("ClientProxy"); + var moduleApiDescription = FindModuleApiDescriptionModel(controller); + + if (moduleApiDescription != null && !moduleApiDescription.RootPath.IsNullOrWhiteSpace()) + { + var selector = controller.Selectors.FirstOrDefault(); + selector?.EndpointMetadata.Add(new AreaAttribute(moduleApiDescription.RootPath)); + controller.RouteValues.Add(new KeyValuePair("area", moduleApiDescription.RootPath)); + } + var controllerApiDescription = FindControllerApiDescriptionModel(controller); if (controllerApiDescription != null && !controllerApiDescription.ControllerGroupName.IsNullOrWhiteSpace())