diff --git a/src/Umbraco.Core/Sync/ApplicationUrlHelper.cs b/src/Umbraco.Core/Sync/ApplicationUrlHelper.cs index d934e24575..f3cc5a6db6 100644 --- a/src/Umbraco.Core/Sync/ApplicationUrlHelper.cs +++ b/src/Umbraco.Core/Sync/ApplicationUrlHelper.cs @@ -112,12 +112,25 @@ namespace Umbraco.Core.Sync /// public static Uri GetApplicationUriUncached( HttpRequestBase request, - IUmbracoSettingsSection umbracoSettingsSection) + IUmbracoSettingsSection umbracoSettingsSection, + IGlobalSettings globalSettings) { var settingUrl = umbracoSettingsSection.WebRouting.UmbracoApplicationUrl; - return string.IsNullOrEmpty(settingUrl) - ? new Uri(request.Url, IOHelper.ResolveUrl(SystemDirectories.Umbraco)) - : new Uri(settingUrl); + + + if (string.IsNullOrEmpty(settingUrl)) + { + if (!Uri.TryCreate(request.Url, VirtualPathUtility.ToAbsolute(globalSettings.Path), out var result)) + { + throw new InvalidOperationException( + $"Could not create an url from {request.Url} and {globalSettings.Path}"); + } + return result; + } + else + { + return new Uri(settingUrl); + } } } } diff --git a/src/Umbraco.Web/Editors/AuthenticationController.cs b/src/Umbraco.Web/Editors/AuthenticationController.cs index 54612377e0..85889c5869 100644 --- a/src/Umbraco.Web/Editors/AuthenticationController.cs +++ b/src/Umbraco.Web/Editors/AuthenticationController.cs @@ -566,7 +566,7 @@ namespace Umbraco.Web.Editors }); // Construct full URL using configured application URL (which will fall back to current request) - var applicationUri = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection); + var applicationUri = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection, GlobalSettings); var callbackUri = new Uri(applicationUri, action); return callbackUri.ToString(); } diff --git a/src/Umbraco.Web/Editors/UsersController.cs b/src/Umbraco.Web/Editors/UsersController.cs index 4bfd72854f..58bb5dcb0a 100644 --- a/src/Umbraco.Web/Editors/UsersController.cs +++ b/src/Umbraco.Web/Editors/UsersController.cs @@ -540,7 +540,7 @@ namespace Umbraco.Web.Editors }); // Construct full URL will use the value in settings if specified, otherwise will use the current request URL - var requestUrl = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection); + var requestUrl = ApplicationUrlHelper.GetApplicationUriUncached(http.Request, _umbracoSettingsSection, GlobalSettings); var inviteUri = new Uri(requestUrl, action); var emailSubject = Services.TextService.Localize("user", "inviteEmailCopySubject",