/// <summary> /// Finds the site root (if any) matching the http request, and updates the PublishedContentRequest accordingly. /// </summary> /// <returns>A value indicating whether a domain was found.</returns> internal bool FindDomain() { const string tracePrefix = "FindDomain: "; // note - we are not handling schemes nor ports here. LogHelper.Debug <PublishedContentRequestEngine>("{0}Uri=\"{1}\"", () => tracePrefix, () => _pcr.Uri); // try to find a domain matching the current request var domainAndUri = DomainHelper.DomainForUri(DomainHelper.GetAllDomains(false), _pcr.Uri); // handle domain if (domainAndUri != null) { // matching an existing domain LogHelper.Debug <PublishedContentRequestEngine>("{0}Matches domain=\"{1}\", rootId={2}, culture=\"{3}\"", () => tracePrefix, () => domainAndUri.Domain.Name, () => domainAndUri.Domain.RootNodeId, () => domainAndUri.Domain.Language.CultureAlias); _pcr.Domain = domainAndUri.Domain; _pcr.DomainUri = domainAndUri.Uri; _pcr.Culture = new CultureInfo(domainAndUri.Domain.Language.CultureAlias); // canonical? not implemented at the moment // if (...) // { // _pcr.RedirectUrl = "..."; // return true; // } } else { // not matching any existing domain LogHelper.Debug <PublishedContentRequestEngine>("{0}Matches no domain", () => tracePrefix); var defaultLanguage = Language.GetAllAsList().FirstOrDefault(); _pcr.Culture = defaultLanguage == null ? CultureInfo.CurrentUICulture : new CultureInfo(defaultLanguage.CultureAlias); } LogHelper.Debug <PublishedContentRequestEngine>("{0}Culture=\"{1}\"", () => tracePrefix, () => _pcr.Culture.Name); return(_pcr.Domain != null); }
/// <summary> /// Finds the site root (if any) matching the http request, and updates the PublishedContentRequest accordingly. /// </summary> /// <returns>A value indicating whether a domain was found.</returns> internal bool FindDomain() { const string tracePrefix = "FindDomain: "; // note - we are not handling schemes nor ports here. ProfilingLogger.Logger.Debug <PublishedContentRequestEngine>("{0}Uri=\"{1}\"", () => tracePrefix, () => _pcr.Uri); // try to find a domain matching the current request var domainAndUri = DomainHelper.DomainForUri(Services.DomainService.GetAll(false), _pcr.Uri); // handle domain if (domainAndUri != null && domainAndUri.UmbracoDomain.LanguageIsoCode.IsNullOrWhiteSpace() == false) { // matching an existing domain ProfilingLogger.Logger.Debug <PublishedContentRequestEngine>("{0}Matches domain=\"{1}\", rootId={2}, culture=\"{3}\"", () => tracePrefix, () => domainAndUri.UmbracoDomain.DomainName, () => domainAndUri.UmbracoDomain.RootContentId, () => domainAndUri.UmbracoDomain.LanguageIsoCode); _pcr.UmbracoDomain = domainAndUri.UmbracoDomain; _pcr.DomainUri = domainAndUri.Uri; _pcr.Culture = new CultureInfo(domainAndUri.UmbracoDomain.LanguageIsoCode); // canonical? not implemented at the moment // if (...) // { // _pcr.RedirectUrl = "..."; // return true; // } } else { // not matching any existing domain ProfilingLogger.Logger.Debug <PublishedContentRequestEngine>("{0}Matches no domain", () => tracePrefix); var defaultLanguage = Services.LocalizationService.GetAllLanguages().FirstOrDefault(); _pcr.Culture = defaultLanguage == null ? CultureInfo.CurrentUICulture : new CultureInfo(defaultLanguage.IsoCode); } ProfilingLogger.Logger.Debug <PublishedContentRequestEngine>("{0}Culture=\"{1}\"", () => tracePrefix, () => _pcr.Culture.Name); return(_pcr.UmbracoDomain != null); }