From d64a0e8aaa39aaa6099a71d9fc5160b9486d1953 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 27 Jul 2010 19:45:22 -0700 Subject: [PATCH] Add "ApplicationPath" in tenant URL --HG-- branch : dev --- .../Extensions/UrlHelperExtensions.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Extensions/UrlHelperExtensions.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Extensions/UrlHelperExtensions.cs index 236d45d23..e9d42249e 100644 --- a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Extensions/UrlHelperExtensions.cs +++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Extensions/UrlHelperExtensions.cs @@ -4,18 +4,24 @@ using Orchard.Environment.Configuration; namespace Orchard.MultiTenancy.Extensions { public static class UrlHelperExtensions { public static string Tenant(this UrlHelper urlHelper, ShellSettings tenantShellSettings) { - //info: (heskew) might not keep the port insertion around beyond... + //info: (heskew) might not keep the port/vdir insertion around beyond... var port = string.Empty; string host = urlHelper.RequestContext.HttpContext.Request.Headers["Host"]; - if(host.Contains(":")) + if (host.Contains(":")) port = host.Substring(host.IndexOf(":")); - return string.Format( - "http://{0}/{1}", - !string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost) - ? tenantShellSettings.RequestUrlHost + port : host, - tenantShellSettings.RequestUrlPrefix); + var result = string.Format("http://{0}", + !string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost) + ? tenantShellSettings.RequestUrlHost + port : host); + + if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix)) + result += "/" + tenantShellSettings.RequestUrlPrefix; + + if (!string.IsNullOrEmpty(urlHelper.RequestContext.HttpContext.Request.ApplicationPath)) + result += urlHelper.RequestContext.HttpContext.Request.ApplicationPath; + + return result; } } } \ No newline at end of file