diff --git a/src/OrchardCore/OrchardCore.Navigation.Core/NavigationManager.cs b/src/OrchardCore/OrchardCore.Navigation.Core/NavigationManager.cs index 32f2ef7a6bc..9b144f2d6cf 100644 --- a/src/OrchardCore/OrchardCore.Navigation.Core/NavigationManager.cs +++ b/src/OrchardCore/OrchardCore.Navigation.Core/NavigationManager.cs @@ -8,6 +8,8 @@ using Microsoft.AspNetCore.Mvc.Routing; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using OrchardCore.Admin; using OrchardCore.Environment.Shell; namespace OrchardCore.Navigation @@ -19,6 +21,7 @@ public class NavigationManager : INavigationManager protected readonly ShellSettings _shellSettings; private readonly IUrlHelperFactory _urlHelperFactory; private readonly IAuthorizationService _authorizationService; + private readonly AdminOptions _adminOptions; private IUrlHelper _urlHelper; @@ -27,7 +30,8 @@ public NavigationManager( ILogger logger, ShellSettings shellSettings, IUrlHelperFactory urlHelperFactory, - IAuthorizationService authorizationService + IAuthorizationService authorizationService, + IOptions adminOptions ) { _navigationProviders = navigationProviders; @@ -35,6 +39,7 @@ IAuthorizationService authorizationService _shellSettings = shellSettings; _urlHelperFactory = urlHelperFactory; _authorizationService = authorizationService; + _adminOptions = adminOptions.Value; } public async Task> BuildMenuAsync(string name, ActionContext actionContext) @@ -203,8 +208,13 @@ private string GetUrl(string menuItemUrl, RouteValueDictionary routeValueDiction menuItemUrl = menuItemUrl.Substring(2); } + if (menuItemUrl.StartsWith($"{_adminOptions.AdminUrlPrefix}/", StringComparison.OrdinalIgnoreCase)) + { + return actionContext.HttpContext.Request.PathBase.Add($"/{menuItemUrl}").Value; + } + // Use the unescaped 'Value' to not encode some possible reserved delimiters. - return actionContext.HttpContext.Request.PathBase.Add('/' + menuItemUrl).Value; + return actionContext.HttpContext.Request.PathBase.Add($"/{_adminOptions.AdminUrlPrefix}/{menuItemUrl}").Value; } /// diff --git a/src/OrchardCore/OrchardCore.Navigation.Core/OrchardCore.Navigation.Core.csproj b/src/OrchardCore/OrchardCore.Navigation.Core/OrchardCore.Navigation.Core.csproj index 44de0240a06..8e08bd71cd1 100644 --- a/src/OrchardCore/OrchardCore.Navigation.Core/OrchardCore.Navigation.Core.csproj +++ b/src/OrchardCore/OrchardCore.Navigation.Core/OrchardCore.Navigation.Core.csproj @@ -14,6 +14,7 @@ +