From 7578d460c4ea5823c66e1feb53f4f0961ebec589 Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Thu, 9 Sep 2021 11:18:12 +0200 Subject: [PATCH] Assign ApplicationMainUrl in constructor of hosting environment if its specified in appsettings --- .../AspNetCore/AspNetCoreHostingEnvironment.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs index bb87ea62bf..19a9074613 100644 --- a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs +++ b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs @@ -39,6 +39,11 @@ namespace Umbraco.Cms.Web.Common.AspNetCore SiteName = webHostEnvironment.ApplicationName; ApplicationPhysicalPath = webHostEnvironment.ContentRootPath; + + if (_webRoutingSettings.CurrentValue.UmbracoApplicationUrl is not null) + { + ApplicationMainUrl = new Uri(_webRoutingSettings.CurrentValue.UmbracoApplicationUrl); + } } /// @@ -58,7 +63,7 @@ namespace Umbraco.Cms.Web.Common.AspNetCore if (_applicationId != null) { return _applicationId; - } + } var appId = _serviceProvider.GetApplicationUniqueIdentifier(); if (appId == null) @@ -173,13 +178,13 @@ namespace Umbraco.Cms.Web.Common.AspNetCore // (this is a simplified version of what was in 7.x) // note: should this be optional? is it expensive? - + if (currentApplicationUrl is null) { return; } - if (!(_webRoutingSettings.CurrentValue.UmbracoApplicationUrl is null)) + if (_webRoutingSettings.CurrentValue.UmbracoApplicationUrl is not null) { return; }