From 59f5810168ba1b96a5cb90ec0156478535bd8f33 Mon Sep 17 00:00:00 2001 From: Berk Arslan Date: Fri, 14 Aug 2020 15:53:28 +0300 Subject: [PATCH] Issue-3982 - SEO Url redirect fix --- .../Components/Pages/PageUrlsController.cs | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Components/Pages/PageUrlsController.cs b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Components/Pages/PageUrlsController.cs index 612e06dbc16..459d087d3d4 100644 --- a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Components/Pages/PageUrlsController.cs +++ b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Components/Pages/PageUrlsController.cs @@ -106,17 +106,30 @@ public PageUrlResult CreateCustomUrl(SaveUrlDto dto, TabInfo tab) } var seqNum = (tab.TabUrls.Count > 0) ? tab.TabUrls.Max(t => t.SeqNum) + 1 : 1; - var portalLocales = LocaleController.Instance.GetLocales(portalSettings.PortalId); - var cultureCode = portalLocales.Where(l => l.Value.KeyID == dto.LocaleKey) - .Select(l => l.Value.Code) - .SingleOrDefault() ?? portalSettings.CultureCode; + var portalLocales = LocaleController.Instance.GetLocales(portalSettings.PortalId); + + // Get the culture code of selected portal alias + var alias = PortalAliasController.Instance + .GetPortalAliasesByPortalId(portalSettings.PortalId) + .SingleOrDefault(a => a.PortalAliasID == dto.SiteAliasKey); + Func, bool> localeFilter = null; + if (alias != null && + !string.IsNullOrWhiteSpace(alias.CultureCode)) + { + localeFilter = l => l.Key == alias.CultureCode; + } + else + { + localeFilter = l => l.Value.KeyID == dto.LocaleKey; + } + + var cultureCode = portalLocales.Where(localeFilter) + .Select(l => l.Value.Code) + .SingleOrDefault() ?? portalSettings.CultureCode; var portalAliasUsage = (PortalAliasUsageType)dto.SiteAliasUsage; if (portalAliasUsage == PortalAliasUsageType.Default) { - var alias = PortalAliasController.Instance.GetPortalAliasesByPortalId(portalSettings.PortalId) - .SingleOrDefault(a => a.PortalAliasID == dto.SiteAliasKey); - if (string.IsNullOrEmpty(cultureCode) || alias == null) { return new PageUrlResult