mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Fixing tenant prefixed urls
This commit is contained in:
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Security;
|
||||
using Orchard.Security.Permissions;
|
||||
@@ -20,7 +19,6 @@ namespace Orchard.Core.Navigation.Services {
|
||||
private readonly IEnumerable<INavigationFilter> _navigationFilters;
|
||||
private readonly UrlHelper _urlHelper;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
|
||||
public NavigationManager(
|
||||
IEnumerable<INavigationProvider> navigationProviders,
|
||||
@@ -28,15 +26,13 @@ namespace Orchard.Core.Navigation.Services {
|
||||
IAuthorizationService authorizationService,
|
||||
IEnumerable<INavigationFilter> navigationFilters,
|
||||
UrlHelper urlHelper,
|
||||
IOrchardServices orchardServices,
|
||||
ShellSettings shellSettings) {
|
||||
IOrchardServices orchardServices) {
|
||||
_navigationProviders = navigationProviders;
|
||||
_menuProviders = menuProviders;
|
||||
_authorizationService = authorizationService;
|
||||
_navigationFilters = navigationFilters;
|
||||
_urlHelper = urlHelper;
|
||||
_orchardServices = orchardServices;
|
||||
_shellSettings = shellSettings;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
@@ -94,9 +90,6 @@ namespace Orchard.Core.Navigation.Services {
|
||||
!(url.StartsWith("/") || schemes.Any(scheme => url.StartsWith(scheme + ":")))) {
|
||||
if (url.StartsWith("~/")) {
|
||||
url = url.Substring(2);
|
||||
if (!String.IsNullOrEmpty(_shellSettings.RequestUrlPrefix)) {
|
||||
url = _shellSettings.RequestUrlPrefix + "/" + url;
|
||||
}
|
||||
}
|
||||
if (!url.StartsWith("#")) {
|
||||
var appPath = _urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
|
||||
|
||||
@@ -190,14 +190,23 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
||||
return writer;
|
||||
}
|
||||
|
||||
private string _tenantPrefix = null;
|
||||
private string _tenantPrefix;
|
||||
public override string Href(string path, params object[] pathParts) {
|
||||
if (_tenantPrefix == null) {
|
||||
_tenantPrefix = WorkContext.Resolve<ShellSettings>().RequestUrlPrefix ?? "";
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(_tenantPrefix)) {
|
||||
return base.Href(path, new [] {_tenantPrefix }.Concat(pathParts).ToArray());
|
||||
|
||||
if (path.StartsWith("~/")
|
||||
&& !path.StartsWith("~/Modules", StringComparison.OrdinalIgnoreCase)
|
||||
&& !path.StartsWith("~/Themes", StringComparison.OrdinalIgnoreCase)
|
||||
&& !path.StartsWith("~/Media", StringComparison.OrdinalIgnoreCase)
|
||||
&& !path.StartsWith("~/Core", StringComparison.OrdinalIgnoreCase)) {
|
||||
|
||||
return base.Href("~/" + _tenantPrefix + path.Substring(2), pathParts);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return base.Href(path, pathParts);
|
||||
|
||||
Reference in New Issue
Block a user