public string TenantUrl(ShellSettings tenantShellSettings) { string result = null; if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost)) { var tenantHosts = tenantShellSettings.RequestUrlHost.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (tenantHosts.Length > 0) { // need to pick suitable host //result = string.Format("//{0}", tenantHosts[0]); result = string.Format("{0}://{1}", _urlHelper.RequestContext.HttpContext.Request.Url.Scheme, tenantHosts[0]); } } if (result == null) { var defaultWorkContext = _twca.GetContext(ShellSettings.DefaultName); result = defaultWorkContext.CurrentSite.BaseUrl; } //application path alwayes in result ??? //var applicationPath = _urlHelper.RequestContext.HttpContext.Request.ApplicationPath; //if (!string.IsNullOrEmpty(applicationPath) && !string.Equals(applicationPath, "/")) // result += applicationPath; if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix)) { result += "/" + tenantShellSettings.RequestUrlPrefix; } return(result); }
public static WorkContext GetDefaultTenantContext(this ITenantWorkContextAccessor tenantWorkContextAccessor) { return(tenantWorkContextAccessor.GetContext(ShellSettings.DefaultName)); }