From 8f7c022f2d13210c039b27ebe0b5b173e94f9e55 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 7 May 2020 09:34:16 +0200 Subject: [PATCH] AB#6233 - Handle ApplicationUrl --- .../Checks/Security/BaseHttpHeaderCheck.cs | 8 +-- .../Checks/Security/ClickJackingCheck.cs | 4 +- .../Checks/Security/ExcessiveHeadersCheck.cs | 8 +-- .../HealthCheck/Checks/Security/HstsCheck.cs | 4 +- .../HealthCheck/Checks/Security/HttpsCheck.cs | 12 ++--- .../Checks/Security/NoSniffCheck.cs | 4 +- .../Checks/Security/XssProtectionCheck.cs | 4 +- .../Hosting/IHostingEnvironment.cs | 2 - src/Umbraco.Core/Scheduling/KeepAlive.cs | 8 +-- src/Umbraco.Core/Services/IRuntimeState.cs | 6 --- .../Sync/SingleServerRegistrar.cs | 9 ++-- src/Umbraco.Core/Web/IRequestAccessor.cs | 2 + ...aseServerRegistrarAndMessengerComponent.cs | 5 +- .../Compose/NotificationsComponent.cs | 8 +-- .../EmailNotificationMethod.cs | 11 ++--- .../Runtime/CoreInitialComposer.cs | 2 +- .../Runtime/CoreRuntime.cs | 2 +- src/Umbraco.Infrastructure/RuntimeState.cs | 49 +------------------ .../Scheduling/SchedulerComponent.cs | 2 +- src/Umbraco.Tests.Common/TestHelperBase.cs | 5 +- .../Routing/UmbracoModuleTests.cs | 2 +- src/Umbraco.Tests/Runtimes/StandaloneTests.cs | 2 +- .../AuthenticationControllerTests.cs | 5 +- .../Web/Controllers/UsersControllerTests.cs | 15 ++++-- .../AspNetCoreHostingEnvironment.cs | 1 - .../AspNetCore/AspNetCoreRequestAccessor.cs | 42 +++++++++++++++- .../Runtime/AspNetCoreComponent.cs | 18 ++++++- src/Umbraco.Web.UI.NetCore/appsettings.json | 4 +- .../AspNet/AspNetHostingEnvironment.cs | 6 +-- .../AspNet/AspNetRequestAccessor.cs | 38 +++++++++++++- .../Editors/AuthenticationController.cs | 7 ++- src/Umbraco.Web/Editors/UsersController.cs | 7 ++- src/Umbraco.Web/UmbracoInjectedModule.cs | 3 -- .../WebApi/UmbracoApiControllerBase.cs | 5 -- 34 files changed, 169 insertions(+), 141 deletions(-) diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/BaseHttpHeaderCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/BaseHttpHeaderCheck.cs index f735c6100a..149ad4a48a 100644 --- a/src/Umbraco.Core/HealthCheck/Checks/Security/BaseHttpHeaderCheck.cs +++ b/src/Umbraco.Core/HealthCheck/Checks/Security/BaseHttpHeaderCheck.cs @@ -14,7 +14,6 @@ namespace Umbraco.Web.HealthCheck.Checks.Security { public abstract class BaseHttpHeaderCheck : HealthCheck { - protected IRuntimeState Runtime { get; } protected ILocalizedTextService TextService { get; } private const string SetHeaderInConfigAction = "setHeaderInConfig"; @@ -23,15 +22,16 @@ namespace Umbraco.Web.HealthCheck.Checks.Security private readonly string _value; private readonly string _localizedTextPrefix; private readonly bool _metaTagOptionAvailable; + private readonly IRequestAccessor _requestAccessor; private readonly IIOHelper _ioHelper; protected BaseHttpHeaderCheck( - IRuntimeState runtime, + IRequestAccessor requestAccessor, ILocalizedTextService textService, string header, string value, string localizedTextPrefix, bool metaTagOptionAvailable, IIOHelper ioHelper) { - Runtime = runtime; TextService = textService ?? throw new ArgumentNullException(nameof(textService)); + _requestAccessor = requestAccessor; _ioHelper = ioHelper; _header = header; _value = value; @@ -72,7 +72,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security var success = false; // Access the site home page and check for the click-jack protection header or meta tag - var url = Runtime.ApplicationUrl; + var url = _requestAccessor.GetApplicationUrl(); var request = WebRequest.Create(url); request.Method = "GET"; try diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/ClickJackingCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/ClickJackingCheck.cs index 2a3a0a9dab..048b26afca 100644 --- a/src/Umbraco.Core/HealthCheck/Checks/Security/ClickJackingCheck.cs +++ b/src/Umbraco.Core/HealthCheck/Checks/Security/ClickJackingCheck.cs @@ -11,8 +11,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Security Group = "Security")] public class ClickJackingCheck : BaseHttpHeaderCheck { - public ClickJackingCheck(IRuntimeState runtime, ILocalizedTextService textService, IIOHelper ioHelper) - : base(runtime, textService, "X-Frame-Options", "sameorigin", "clickJacking", true, ioHelper) + public ClickJackingCheck(IRequestAccessor requestAccessor, ILocalizedTextService textService, IIOHelper ioHelper) + : base(requestAccessor, textService, "X-Frame-Options", "sameorigin", "clickJacking", true, ioHelper) { } } diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/ExcessiveHeadersCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/ExcessiveHeadersCheck.cs index 6fa6e8b37e..06367ace13 100644 --- a/src/Umbraco.Core/HealthCheck/Checks/Security/ExcessiveHeadersCheck.cs +++ b/src/Umbraco.Core/HealthCheck/Checks/Security/ExcessiveHeadersCheck.cs @@ -15,12 +15,12 @@ namespace Umbraco.Web.HealthCheck.Checks.Security public class ExcessiveHeadersCheck : HealthCheck { private readonly ILocalizedTextService _textService; - private readonly IRuntimeState _runtime; + private readonly IRequestAccessor _requestAccessor; - public ExcessiveHeadersCheck(ILocalizedTextService textService, IRuntimeState runtime) + public ExcessiveHeadersCheck(ILocalizedTextService textService, IRequestAccessor requestAccessor) { _textService = textService; - _runtime = runtime; + _requestAccessor = requestAccessor; } /// @@ -47,7 +47,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security { var message = string.Empty; var success = false; - var url = _runtime.ApplicationUrl; + var url = _requestAccessor.GetApplicationUrl(); // Access the site home page and check for the headers var request = WebRequest.Create(url); diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/HstsCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/HstsCheck.cs index 7ce7a80c93..61879142f2 100644 --- a/src/Umbraco.Core/HealthCheck/Checks/Security/HstsCheck.cs +++ b/src/Umbraco.Core/HealthCheck/Checks/Security/HstsCheck.cs @@ -16,8 +16,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Security // and the blog post of Troy Hunt (https://www.troyhunt.com/understanding-http-strict-transport/) // If you want do to it perfectly, you have to submit it https://hstspreload.org/, // but then you should include subdomains and I wouldn't suggest to do that for Umbraco-sites. - public HstsCheck(IRuntimeState runtime, ILocalizedTextService textService, IIOHelper ioHelper) - : base(runtime, textService, "Strict-Transport-Security", "max-age=10886400", "hSTS", true, ioHelper) + public HstsCheck(IRequestAccessor requestAccessor, ILocalizedTextService textService, IIOHelper ioHelper) + : base(requestAccessor, textService, "Strict-Transport-Security", "max-age=10886400", "hSTS", true, ioHelper) { } } diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/HttpsCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/HttpsCheck.cs index 615748b93e..43776ad827 100644 --- a/src/Umbraco.Core/HealthCheck/Checks/Security/HttpsCheck.cs +++ b/src/Umbraco.Core/HealthCheck/Checks/Security/HttpsCheck.cs @@ -19,20 +19,20 @@ namespace Umbraco.Web.HealthCheck.Checks.Security public class HttpsCheck : HealthCheck { private readonly ILocalizedTextService _textService; - private readonly IRuntimeState _runtime; private readonly IGlobalSettings _globalSettings; private readonly IIOHelper _ioHelper; private readonly ILogger _logger; + private readonly IRequestAccessor _requestAccessor; private const string FixHttpsSettingAction = "fixHttpsSetting"; - public HttpsCheck(ILocalizedTextService textService, IRuntimeState runtime, IGlobalSettings globalSettings, IIOHelper ioHelper, ILogger logger) + public HttpsCheck(ILocalizedTextService textService, IGlobalSettings globalSettings, IIOHelper ioHelper, ILogger logger, IRequestAccessor requestAccessor) { _textService = textService; - _runtime = runtime; _globalSettings = globalSettings; _ioHelper = ioHelper; _logger = logger; + _requestAccessor = requestAccessor; } /// @@ -68,7 +68,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security // Attempt to access the site over HTTPS to see if it HTTPS is supported // and a valid certificate has been configured - var url = _runtime.ApplicationUrl.ToString().Replace("http:", "https:"); + var url = _requestAccessor.GetApplicationUrl().ToString().Replace("http:", "https:"); var request = (HttpWebRequest) WebRequest.Create(url); request.Method = "HEAD"; @@ -136,7 +136,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security private HealthCheckStatus CheckIfCurrentSchemeIsHttps() { - var uri = _runtime.ApplicationUrl; + var uri = _requestAccessor.GetApplicationUrl(); var success = uri.Scheme == "https"; var actions = new List(); @@ -152,7 +152,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security private HealthCheckStatus CheckHttpsConfigurationSetting() { var httpsSettingEnabled = _globalSettings.UseHttps; - var uri = _runtime.ApplicationUrl; + var uri = _requestAccessor.GetApplicationUrl(); var actions = new List(); string resultMessage; diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/NoSniffCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/NoSniffCheck.cs index 392d8c94db..0b6fb9e347 100644 --- a/src/Umbraco.Core/HealthCheck/Checks/Security/NoSniffCheck.cs +++ b/src/Umbraco.Core/HealthCheck/Checks/Security/NoSniffCheck.cs @@ -11,8 +11,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Security Group = "Security")] public class NoSniffCheck : BaseHttpHeaderCheck { - public NoSniffCheck(IRuntimeState runtime, ILocalizedTextService textService, IIOHelper ioHelper) - : base(runtime, textService, "X-Content-Type-Options", "nosniff", "noSniff", false, ioHelper) + public NoSniffCheck(IRequestAccessor requestAccessor, ILocalizedTextService textService, IIOHelper ioHelper) + : base(requestAccessor, textService, "X-Content-Type-Options", "nosniff", "noSniff", false, ioHelper) { } } diff --git a/src/Umbraco.Core/HealthCheck/Checks/Security/XssProtectionCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Security/XssProtectionCheck.cs index 8881221923..7d658e2082 100644 --- a/src/Umbraco.Core/HealthCheck/Checks/Security/XssProtectionCheck.cs +++ b/src/Umbraco.Core/HealthCheck/Checks/Security/XssProtectionCheck.cs @@ -16,8 +16,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Security // and the blog post of Troy Hunt (https://www.troyhunt.com/understanding-http-strict-transport/) // If you want do to it perfectly, you have to submit it https://hstspreload.appspot.com/, // but then you should include subdomains and I wouldn't suggest to do that for Umbraco-sites. - public XssProtectionCheck(IRuntimeState runtime, ILocalizedTextService textService, IIOHelper ioHelper) - : base(runtime, textService, "X-XSS-Protection", "1; mode=block", "xssProtection", true, ioHelper) + public XssProtectionCheck(IRequestAccessor requestAccessor,ILocalizedTextService textService, IIOHelper ioHelper) + : base(requestAccessor, textService, "X-XSS-Protection", "1; mode=block", "xssProtection", true, ioHelper) { } } diff --git a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs index a7ed204ee7..188fb87b55 100644 --- a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs +++ b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs @@ -23,8 +23,6 @@ namespace Umbraco.Core.Hosting /// string ApplicationVirtualPath { get; } - string ApplicationServerAddress { get; } - bool IsDebugMode { get; } /// diff --git a/src/Umbraco.Core/Scheduling/KeepAlive.cs b/src/Umbraco.Core/Scheduling/KeepAlive.cs index 1c4ef075ae..a47080912c 100644 --- a/src/Umbraco.Core/Scheduling/KeepAlive.cs +++ b/src/Umbraco.Core/Scheduling/KeepAlive.cs @@ -11,7 +11,7 @@ namespace Umbraco.Web.Scheduling { public class KeepAlive : RecurringTaskBase { - private readonly IRuntimeState _runtimeState; + private readonly IRequestAccessor _requestAccessor; private readonly IMainDom _mainDom; private readonly IKeepAliveSettings _keepAliveSettings; private readonly IProfilingLogger _logger; @@ -19,10 +19,10 @@ namespace Umbraco.Web.Scheduling private static HttpClient _httpClient; public KeepAlive(IBackgroundTaskRunner runner, int delayMilliseconds, int periodMilliseconds, - IRuntimeState runtimeState, IMainDom mainDom, IKeepAliveSettings keepAliveSettings, IProfilingLogger logger, IServerRegistrar serverRegistrar) + IRequestAccessor requestAccessor, IMainDom mainDom, IKeepAliveSettings keepAliveSettings, IProfilingLogger logger, IServerRegistrar serverRegistrar) : base(runner, delayMilliseconds, periodMilliseconds) { - _runtimeState = runtimeState; + _requestAccessor = requestAccessor; _mainDom = mainDom; _keepAliveSettings = keepAliveSettings; _logger = logger; @@ -58,7 +58,7 @@ namespace Umbraco.Web.Scheduling { if (keepAlivePingUrl.Contains("{umbracoApplicationUrl}")) { - var umbracoAppUrl = _runtimeState.ApplicationUrl.ToString(); + var umbracoAppUrl = _requestAccessor.GetApplicationUrl().ToString(); if (umbracoAppUrl.IsNullOrWhiteSpace()) { _logger.Warn("No umbracoApplicationUrl for service (yet), skip."); diff --git a/src/Umbraco.Core/Services/IRuntimeState.cs b/src/Umbraco.Core/Services/IRuntimeState.cs index 4b5e26651b..4b57908ea7 100644 --- a/src/Umbraco.Core/Services/IRuntimeState.cs +++ b/src/Umbraco.Core/Services/IRuntimeState.cs @@ -25,12 +25,6 @@ namespace Umbraco.Core /// SemVersion SemanticVersion { get; } - /// - /// Gets the Umbraco application url. - /// - /// This is eg "http://www.example.com". - Uri ApplicationUrl { get; } - /// /// Gets the runtime level of execution. /// diff --git a/src/Umbraco.Core/Sync/SingleServerRegistrar.cs b/src/Umbraco.Core/Sync/SingleServerRegistrar.cs index c423c6e624..fe03e195b2 100644 --- a/src/Umbraco.Core/Sync/SingleServerRegistrar.cs +++ b/src/Umbraco.Core/Sync/SingleServerRegistrar.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Umbraco.Web; namespace Umbraco.Core.Sync { @@ -13,15 +14,15 @@ namespace Umbraco.Core.Sync /// public class SingleServerRegistrar : IServerRegistrar { - private readonly IRuntimeState _runtime; + private readonly IRequestAccessor _requestAccessor; private readonly Lazy _registrations; public IEnumerable Registrations => _registrations.Value; - public SingleServerRegistrar(IRuntimeState runtime) + public SingleServerRegistrar(IRequestAccessor requestAccessor) { - _runtime = runtime; - _registrations = new Lazy(() => new IServerAddress[] { new ServerAddressImpl(_runtime.ApplicationUrl.ToString()) }); + _requestAccessor = requestAccessor; + _registrations = new Lazy(() => new IServerAddress[] { new ServerAddressImpl(_requestAccessor.GetApplicationUrl().ToString()) }); } public ServerRole GetCurrentServerRole() diff --git a/src/Umbraco.Core/Web/IRequestAccessor.cs b/src/Umbraco.Core/Web/IRequestAccessor.cs index 7dc77d3c29..aa2a36f795 100644 --- a/src/Umbraco.Core/Web/IRequestAccessor.cs +++ b/src/Umbraco.Core/Web/IRequestAccessor.cs @@ -10,5 +10,7 @@ namespace Umbraco.Web event EventHandler EndRequest; event EventHandler RouteAttempt; Uri GetRequestUrl(); + + Uri GetApplicationUrl(); } } diff --git a/src/Umbraco.Infrastructure/Compose/DatabaseServerRegistrarAndMessengerComponent.cs b/src/Umbraco.Infrastructure/Compose/DatabaseServerRegistrarAndMessengerComponent.cs index fdc672c534..afd6227359 100644 --- a/src/Umbraco.Infrastructure/Compose/DatabaseServerRegistrarAndMessengerComponent.cs +++ b/src/Umbraco.Infrastructure/Compose/DatabaseServerRegistrarAndMessengerComponent.cs @@ -83,7 +83,6 @@ namespace Umbraco.Web.Compose private object _locker = new object(); private readonly DatabaseServerRegistrar _registrar; private readonly IBatchedDatabaseServerMessenger _messenger; - private readonly IRuntimeState _runtime; private readonly ILogger _logger; private readonly IServerRegistrationService _registrationService; private readonly BackgroundTaskRunner _touchTaskRunner; @@ -93,7 +92,6 @@ namespace Umbraco.Web.Compose private readonly IRequestAccessor _requestAccessor; public DatabaseServerRegistrarAndMessengerComponent( - IRuntimeState runtime, IServerRegistrar serverRegistrar, IServerMessenger serverMessenger, IServerRegistrationService registrationService, @@ -101,7 +99,6 @@ namespace Umbraco.Web.Compose IApplicationShutdownRegistry hostingEnvironment, IRequestAccessor requestAccessor) { - _runtime = runtime; _logger = logger; _registrationService = registrationService; _requestAccessor = requestAccessor; @@ -164,7 +161,7 @@ namespace Umbraco.Web.Compose // only perform this one time ever LazyInitializer.EnsureInitialized(ref _tasks, ref _started, ref _locker, () => { - var serverAddress = _runtime.ApplicationUrl.ToString(); + var serverAddress = _requestAccessor.GetApplicationUrl().ToString(); return new[] { diff --git a/src/Umbraco.Infrastructure/Compose/NotificationsComponent.cs b/src/Umbraco.Infrastructure/Compose/NotificationsComponent.cs index b39e5c03e9..3a4b8a5fac 100644 --- a/src/Umbraco.Infrastructure/Compose/NotificationsComponent.cs +++ b/src/Umbraco.Infrastructure/Compose/NotificationsComponent.cs @@ -149,7 +149,7 @@ namespace Umbraco.Web.Compose public sealed class Notifier { private readonly IUmbracoContextAccessor _umbracoContextAccessor; - private readonly IRuntimeState _runtimeState; + private readonly IRequestAccessor _requestAccessor; private readonly INotificationService _notificationService; private readonly IUserService _userService; private readonly ILocalizedTextService _textService; @@ -166,10 +166,10 @@ namespace Umbraco.Web.Compose /// /// /// - public Notifier(IUmbracoContextAccessor umbracoContextAccessor, IRuntimeState runtimeState, INotificationService notificationService, IUserService userService, ILocalizedTextService textService, IGlobalSettings globalSettings, ILogger logger) + public Notifier(IUmbracoContextAccessor umbracoContextAccessor, IRequestAccessor requestAccessor, INotificationService notificationService, IUserService userService, ILocalizedTextService textService, IGlobalSettings globalSettings, ILogger logger) { _umbracoContextAccessor = umbracoContextAccessor; - _runtimeState = runtimeState; + _requestAccessor = requestAccessor; _notificationService = notificationService; _userService = userService; _textService = textService; @@ -193,7 +193,7 @@ namespace Umbraco.Web.Compose } } - SendNotification(user, entities, action, _runtimeState.ApplicationUrl); + SendNotification(user, entities, action, _requestAccessor.GetApplicationUrl()); } private void SendNotification(IUser sender, IEnumerable entities, IAction action, Uri siteUri) diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs index dcd539c4a2..0240d60f29 100644 --- a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs +++ b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs @@ -15,12 +15,12 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods public class EmailNotificationMethod : NotificationMethodBase { private readonly ILocalizedTextService _textService; - private readonly IRuntimeState _runtimeState; - private readonly ILogger _logger; + private readonly IRequestAccessor _requestAccessor; + private readonly IGlobalSettings _globalSettings; private readonly IContentSettings _contentSettings; - public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecksSettings healthChecksSettings, IContentSettings contentSettings) : base(healthChecksSettings) + public EmailNotificationMethod(ILocalizedTextService textService, IRequestAccessor requestAccessor, IGlobalSettings globalSettings, IHealthChecksSettings healthChecksSettings, IContentSettings contentSettings) : base(healthChecksSettings) { var recipientEmail = Settings?["recipientEmail"]?.Value; if (string.IsNullOrWhiteSpace(recipientEmail)) @@ -32,8 +32,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods RecipientEmail = recipientEmail; _textService = textService ?? throw new ArgumentNullException(nameof(textService)); - _runtimeState = runtimeState; - _logger = logger; + _requestAccessor = requestAccessor; _globalSettings = globalSettings; _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); } @@ -61,7 +60,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods // Include the umbraco Application URL host in the message subject so that // you can identify the site that these results are for. - var host = _runtimeState.ApplicationUrl; + var host = _requestAccessor.GetApplicationUrl(); var subject = _textService.Localize("healthcheck/scheduledHealthCheckEmailSubject", new[] { host.ToString() }); diff --git a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs index 38204d9452..f28a97303e 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs @@ -128,7 +128,7 @@ namespace Umbraco.Core.Runtime // even on 1 single server we can have 2 concurrent app domains var singleServer = globalSettings.DisableElectionForSingleServer; return singleServer - ? (IServerRegistrar) new SingleServerRegistrar(f.GetInstance()) + ? (IServerRegistrar) new SingleServerRegistrar(f.GetInstance()) : new DatabaseServerRegistrar( new Lazy(f.GetInstance), new DatabaseServerRegistrarOptions()); diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs index 347589b7c8..32e646afca 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs @@ -65,7 +65,7 @@ namespace Umbraco.Core.Runtime // runtime state // beware! must use '() => _factory.GetInstance()' and NOT '_factory.GetInstance' // as the second one captures the current value (null) and therefore fails - _state = new RuntimeState(Logger, Configs.Global(), UmbracoVersion, BackOfficeInfo, HostingEnvironment) + _state = new RuntimeState(Configs.Global(), UmbracoVersion) { Level = RuntimeLevel.Boot }; diff --git a/src/Umbraco.Infrastructure/RuntimeState.cs b/src/Umbraco.Infrastructure/RuntimeState.cs index 3d8335734e..4a33291314 100644 --- a/src/Umbraco.Infrastructure/RuntimeState.cs +++ b/src/Umbraco.Infrastructure/RuntimeState.cs @@ -3,14 +3,11 @@ using System.Threading; using Semver; using Umbraco.Core.Collections; using Umbraco.Core.Configuration; -using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Exceptions; using Umbraco.Core.Hosting; using Umbraco.Core.Logging; using Umbraco.Core.Migrations.Upgrade; using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Repositories.Implement; -using Umbraco.Core.Sync; namespace Umbraco.Core { @@ -19,27 +16,16 @@ namespace Umbraco.Core /// public class RuntimeState : IRuntimeState { - private readonly ILogger _logger; private readonly IGlobalSettings _globalSettings; - private readonly ConcurrentHashSet _applicationUrls = new ConcurrentHashSet(); private readonly IUmbracoVersion _umbracoVersion; - private readonly IBackOfficeInfo _backOfficeInfo; - private readonly IHostingEnvironment _hostingEnvironment; - private Uri _applicationUrl; /// /// Initializes a new instance of the class. /// - public RuntimeState(ILogger logger, IGlobalSettings globalSettings, - IUmbracoVersion umbracoVersion, - IBackOfficeInfo backOfficeInfo, - IHostingEnvironment hostingEnvironment) + public RuntimeState(IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion) { - _logger = logger; _globalSettings = globalSettings; _umbracoVersion = umbracoVersion; - _backOfficeInfo = backOfficeInfo; - _hostingEnvironment = hostingEnvironment; } @@ -52,13 +38,6 @@ namespace Umbraco.Core /// public SemVersion SemanticVersion => _umbracoVersion.SemanticVersion; - /// - public Uri ApplicationUrl - { - get => _applicationUrl ??= new Uri(_hostingEnvironment.ApplicationServerAddress); - private set => _applicationUrl = value; - } - /// public string CurrentMigrationState { get; private set; } @@ -71,32 +50,6 @@ namespace Umbraco.Core /// public RuntimeLevelReason Reason { get; internal set; } = RuntimeLevelReason.Unknown; - - /// - /// Ensures that the property has a value. - /// - public void EnsureApplicationUrl() - { - //Fixme: This causes problems with site swap on azure because azure pre-warms a site by calling into `localhost` and when it does that - // it changes the URL to `localhost:80` which actually doesn't work for pinging itself, it only works internally in Azure. The ironic part - // about this is that this is here specifically for the slot swap scenario https://issues.umbraco.org/issue/U4-10626 - - - // see U4-10626 - in some cases we want to reset the application url - // (this is a simplified version of what was in 7.x) - // note: should this be optional? is it expensive? - var url = _backOfficeInfo.GetAbsoluteUrl; - - var change = url != null && !_applicationUrls.Contains(url); - - if (change) - { - _logger.Info("New url {Url} detected, re-discovering application url.", url); - _applicationUrls.Add(url); - ApplicationUrl = new Uri(url); - } - } - /// public BootFailedException BootFailedException { get; internal set; } diff --git a/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs b/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs index 3c58cbbde7..094258b881 100644 --- a/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs +++ b/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs @@ -139,7 +139,7 @@ namespace Umbraco.Web.Scheduling { // ping/keepalive // on all servers - var task = new KeepAlive(_keepAliveRunner, DefaultDelayMilliseconds, FiveMinuteMilliseconds, _runtime, _mainDom, keepAliveSettings, _logger, _serverRegistrar); + var task = new KeepAlive(_keepAliveRunner, DefaultDelayMilliseconds, FiveMinuteMilliseconds, _requestAccessor, _mainDom, keepAliveSettings, _logger, _serverRegistrar); _keepAliveRunner.TryAdd(task); return task; } diff --git a/src/Umbraco.Tests.Common/TestHelperBase.cs b/src/Umbraco.Tests.Common/TestHelperBase.cs index 9f3735a616..ce20e723df 100644 --- a/src/Umbraco.Tests.Common/TestHelperBase.cs +++ b/src/Umbraco.Tests.Common/TestHelperBase.cs @@ -51,11 +51,8 @@ namespace Umbraco.Tests.Common public IRuntimeState GetRuntimeState() { return new RuntimeState( - Mock.Of(), Mock.Of(), - GetUmbracoVersion(), - GetBackOfficeInfo(), - GetHostingEnvironment()); + GetUmbracoVersion()); } public abstract IBackOfficeInfo GetBackOfficeInfo(); diff --git a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs index a4819582dc..0165e7714f 100644 --- a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs +++ b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs @@ -32,7 +32,7 @@ namespace Umbraco.Tests.Routing //create the module var logger = Mock.Of(); var globalSettings = TestObjects.GetGlobalSettings(); - var runtime = new RuntimeState(logger, globalSettings, UmbracoVersion, BackOfficeInfo, HostingEnvironment); + var runtime = new RuntimeState(globalSettings, UmbracoVersion); _module = new UmbracoInjectedModule ( diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs index 3088af0b5a..ac0ff3f9f9 100644 --- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs +++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs @@ -73,7 +73,7 @@ namespace Umbraco.Tests.Runtimes var mainDom = new SimpleMainDom(); var umbracoVersion = TestHelper.GetUmbracoVersion(); var backOfficeInfo = TestHelper.GetBackOfficeInfo(); - var runtimeState = new RuntimeState(logger, null, umbracoVersion, backOfficeInfo, hostingEnvironment); + var runtimeState = new RuntimeState(null, umbracoVersion); var configs = TestHelper.GetConfigs(); var variationContextAccessor = TestHelper.VariationContextAccessor; diff --git a/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs b/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs index d4f21faf09..652541da0c 100644 --- a/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs +++ b/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs @@ -92,8 +92,9 @@ namespace Umbraco.Tests.Web.Controllers Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), - Factory.GetInstance() - ); + Factory.GetInstance(), + Factory.GetInstance() + ); return usersController; } diff --git a/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs b/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs index 83c5d3f87d..8c40085e50 100644 --- a/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs +++ b/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs @@ -104,7 +104,8 @@ namespace Umbraco.Tests.Web.Controllers Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), - Factory.GetInstance() + Factory.GetInstance(), + Factory.GetInstance() ); return usersController; @@ -177,7 +178,8 @@ namespace Umbraco.Tests.Web.Controllers Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), - Factory.GetInstance() + Factory.GetInstance(), + Factory.GetInstance() ); return usersController; } @@ -220,7 +222,8 @@ namespace Umbraco.Tests.Web.Controllers Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), - Factory.GetInstance() + Factory.GetInstance(), + Factory.GetInstance() ); return usersController; } @@ -298,7 +301,8 @@ namespace Umbraco.Tests.Web.Controllers Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), - Factory.GetInstance() + Factory.GetInstance(), + Factory.GetInstance() ); return usersController; } @@ -488,7 +492,8 @@ namespace Umbraco.Tests.Web.Controllers Factory.GetInstance(), Factory.GetInstance(), Factory.GetInstance(), - Factory.GetInstance()); + Factory.GetInstance(), + Factory.GetInstance()); var mockOwinContext = new Mock(); var mockUserManagerMarker = new Mock(); diff --git a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs index 9285849430..f5b1b988cf 100644 --- a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs +++ b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs @@ -23,7 +23,6 @@ namespace Umbraco.Web.Common.AspNetCore ApplicationPhysicalPath = webHostEnvironment.ContentRootPath; ApplicationVirtualPath = "/"; //TODO how to find this, This is a server thing, not application thing. - ApplicationServerAddress = "https://localhost:44354"; // TODO how to find this? IISVersion = new Version(0, 0); // TODO not necessary IIS } diff --git a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreRequestAccessor.cs b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreRequestAccessor.cs index e323278809..c9bf38e9a1 100644 --- a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreRequestAccessor.cs +++ b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreRequestAccessor.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Web.Common.Extensions; using Umbraco.Web.Common.Lifetime; using Umbraco.Web.Routing; @@ -11,11 +13,18 @@ namespace Umbraco.Web.Common.AspNetCore { private readonly IHttpContextAccessor _httpContextAccessor; private readonly IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IWebRoutingSettings _webRoutingSettings; + private readonly ISet _applicationUrls = new HashSet(); + private Uri _currentApplicationUrl; - public AspNetCoreRequestAccessor(IHttpContextAccessor httpContextAccessor, IUmbracoRequestLifetime umbracoRequestLifetime, IUmbracoContextAccessor umbracoContextAccessor) + public AspNetCoreRequestAccessor(IHttpContextAccessor httpContextAccessor, + IUmbracoRequestLifetime umbracoRequestLifetime, + IUmbracoContextAccessor umbracoContextAccessor, + IWebRoutingSettings webRoutingSettings) { _httpContextAccessor = httpContextAccessor; _umbracoContextAccessor = umbracoContextAccessor; + _webRoutingSettings = webRoutingSettings; umbracoRequestLifetime.RequestStart += RequestStart; umbracoRequestLifetime.RequestEnd += RequestEnd; @@ -43,5 +52,36 @@ namespace Umbraco.Web.Common.AspNetCore public event EventHandler RouteAttempt; public Uri GetRequestUrl() => _httpContextAccessor.HttpContext != null ? new Uri(_httpContextAccessor.HttpContext.Request.GetEncodedUrl()) : null; + public Uri GetApplicationUrl() + { + //Fixme: This causes problems with site swap on azure because azure pre-warms a site by calling into `localhost` and when it does that + // it changes the URL to `localhost:80` which actually doesn't work for pinging itself, it only works internally in Azure. The ironic part + // about this is that this is here specifically for the slot swap scenario https://issues.umbraco.org/issue/U4-10626 + + + // see U4-10626 - in some cases we want to reset the application url + // (this is a simplified version of what was in 7.x) + // note: should this be optional? is it expensive? + + if (!(_webRoutingSettings.UmbracoApplicationUrl is null)) + { + return new Uri(_webRoutingSettings.UmbracoApplicationUrl); + } + + var request = _httpContextAccessor.HttpContext?.Request; + + if (request is null) return _currentApplicationUrl; + + var url = UriHelper.BuildAbsolute(request.Scheme, request.Host); + var change = url != null && !_applicationUrls.Contains(url); + if (change) + { + _applicationUrls.Add(url); + + _currentApplicationUrl ??= new Uri(url); + } + + return _currentApplicationUrl; + } } } diff --git a/src/Umbraco.Web.Common/Runtime/AspNetCoreComponent.cs b/src/Umbraco.Web.Common/Runtime/AspNetCoreComponent.cs index 991dce55e6..e2bb024df5 100644 --- a/src/Umbraco.Web.Common/Runtime/AspNetCoreComponent.cs +++ b/src/Umbraco.Web.Common/Runtime/AspNetCoreComponent.cs @@ -1,6 +1,10 @@ -using Microsoft.Extensions.Hosting; +using System; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Hosting; +using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Net; +using Umbraco.Web.Common.Lifetime; namespace Umbraco.Web.Common.Runtime { @@ -8,11 +12,19 @@ namespace Umbraco.Web.Common.Runtime { private readonly IHostApplicationLifetime _hostApplicationLifetime; private readonly IUmbracoApplicationLifetimeManager _umbracoApplicationLifetimeManager; + private readonly IUmbracoRequestLifetime _umbracoRequestLifetime; + private readonly IRuntimeState _runtimeState; - public AspNetCoreComponent(IHostApplicationLifetime hostApplicationLifetime, IUmbracoApplicationLifetimeManager umbracoApplicationLifetimeManager) + public AspNetCoreComponent( + IHostApplicationLifetime hostApplicationLifetime, + IUmbracoApplicationLifetimeManager umbracoApplicationLifetimeManager, + IUmbracoRequestLifetime umbracoRequestLifetime, + IRuntimeState runtimeState) { _hostApplicationLifetime = hostApplicationLifetime; _umbracoApplicationLifetimeManager = umbracoApplicationLifetimeManager; + _umbracoRequestLifetime = umbracoRequestLifetime; + _runtimeState = runtimeState; } public void Initialize() @@ -22,6 +34,8 @@ namespace Umbraco.Web.Common.Runtime }); } + + public void Terminate() { } diff --git a/src/Umbraco.Web.UI.NetCore/appsettings.json b/src/Umbraco.Web.UI.NetCore/appsettings.json index 29be35e386..b3a621de88 100644 --- a/src/Umbraco.Web.UI.NetCore/appsettings.json +++ b/src/Umbraco.Web.UI.NetCore/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "umbracoDbDSN": "" + "umbracoDbDSN": "Server=(LocalDb)\\Umbraco;Database=NetCore2;Integrated Security=true" }, "Logging": { "LogLevel": { @@ -119,4 +119,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs index df04d5cfac..5e7324236a 100644 --- a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs +++ b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs @@ -13,7 +13,7 @@ namespace Umbraco.Web.Hosting private readonly IHostingSettings _hostingSettings; private string _localTempPath; - private string _applicationServerAddress; + public AspNetHostingEnvironment(IHostingSettings hostingSettings) { @@ -26,8 +26,6 @@ namespace Umbraco.Web.Hosting ?? HostingEnvironment.ApplicationVirtualPath?.EnsureStartsWith("/") ?? "/"; IISVersion = HttpRuntime.IISVersion; - - ApplicationServerAddress = "https://localhost:44354"; // TODO how to find this? } public string SiteName { get; } @@ -36,8 +34,6 @@ namespace Umbraco.Web.Hosting public string ApplicationVirtualPath { get; } - public string ApplicationServerAddress { get; } - public bool IsDebugMode => HttpContext.Current?.IsDebuggingEnabled ?? _hostingSettings.DebugMode; /// public bool IsHosted => (HttpContext.Current != null || HostingEnvironment.IsHosted); diff --git a/src/Umbraco.Web/AspNet/AspNetRequestAccessor.cs b/src/Umbraco.Web/AspNet/AspNetRequestAccessor.cs index 66a21af078..aa2cba6949 100644 --- a/src/Umbraco.Web/AspNet/AspNetRequestAccessor.cs +++ b/src/Umbraco.Web/AspNet/AspNetRequestAccessor.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Web.Routing; namespace Umbraco.Web.AspNet @@ -6,10 +8,13 @@ namespace Umbraco.Web.AspNet public class AspNetRequestAccessor : IRequestAccessor { private readonly IHttpContextAccessor _httpContextAccessor; - - public AspNetRequestAccessor(IHttpContextAccessor httpContextAccessor) + private readonly IWebRoutingSettings _webRoutingSettings; + private readonly ISet _applicationUrls = new HashSet(); + private Uri _currentApplicationUrl; + public AspNetRequestAccessor(IHttpContextAccessor httpContextAccessor, IWebRoutingSettings webRoutingSettings) { _httpContextAccessor = httpContextAccessor; + _webRoutingSettings = webRoutingSettings; UmbracoModule.EndRequest += OnEndRequest; UmbracoModule.RouteAttempt += OnRouteAttempt; @@ -39,5 +44,34 @@ namespace Umbraco.Web.AspNet public event EventHandler EndRequest; public event EventHandler RouteAttempt; public Uri GetRequestUrl() => _httpContextAccessor.HttpContext?.Request.Url; + public Uri GetApplicationUrl() + { + //Fixme: This causes problems with site swap on azure because azure pre-warms a site by calling into `localhost` and when it does that + // it changes the URL to `localhost:80` which actually doesn't work for pinging itself, it only works internally in Azure. The ironic part + // about this is that this is here specifically for the slot swap scenario https://issues.umbraco.org/issue/U4-10626 + + + // see U4-10626 - in some cases we want to reset the application url + // (this is a simplified version of what was in 7.x) + // note: should this be optional? is it expensive? + + if (!(_webRoutingSettings.UmbracoApplicationUrl is null)) + { + return new Uri(_webRoutingSettings.UmbracoApplicationUrl); + } + + var request = _httpContextAccessor.HttpContext?.Request; + + var url = request?.Url.GetLeftPart(UriPartial.Authority); + var change = url != null && !_applicationUrls.Contains(url); + if (change) + { + _applicationUrls.Add(url); + + _currentApplicationUrl ??= new Uri(url); + } + + return _currentApplicationUrl; + } } } diff --git a/src/Umbraco.Web/Editors/AuthenticationController.cs b/src/Umbraco.Web/Editors/AuthenticationController.cs index fc34a35566..009d970fd5 100644 --- a/src/Umbraco.Web/Editors/AuthenticationController.cs +++ b/src/Umbraco.Web/Editors/AuthenticationController.cs @@ -47,6 +47,7 @@ namespace Umbraco.Web.Editors private readonly IHostingEnvironment _hostingEnvironment; private readonly IRuntimeState _runtimeState; private readonly ISecuritySettings _securitySettings; + private readonly IRequestAccessor _requestAccessor; public AuthenticationController( IUserPasswordConfiguration passwordConfiguration, @@ -60,13 +61,15 @@ namespace Umbraco.Web.Editors IRuntimeState runtimeState, UmbracoMapper umbracoMapper, ISecuritySettings securitySettings, - IPublishedUrlProvider publishedUrlProvider) + IPublishedUrlProvider publishedUrlProvider, + IRequestAccessor requestAccessor) : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider) { _passwordConfiguration = passwordConfiguration ?? throw new ArgumentNullException(nameof(passwordConfiguration)); _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment)); _runtimeState = runtimeState ?? throw new ArgumentNullException(nameof(runtimeState)); _securitySettings = securitySettings ?? throw new ArgumentNullException(nameof(securitySettings)); + _requestAccessor = requestAccessor ?? throw new ArgumentNullException(nameof(securitySettings)); } protected BackOfficeUserManager UserManager => _userManager @@ -545,7 +548,7 @@ namespace Umbraco.Web.Editors }); // Construct full URL using configured application URL (which will fall back to request) - var applicationUri = _runtimeState.ApplicationUrl; + var applicationUri = _requestAccessor.GetApplicationUrl(); 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 30cd91ac5d..e695139b8c 100644 --- a/src/Umbraco.Web/Editors/UsersController.cs +++ b/src/Umbraco.Web/Editors/UsersController.cs @@ -52,6 +52,7 @@ namespace Umbraco.Web.Editors private readonly ISqlContext _sqlContext; private readonly IImageUrlGenerator _imageUrlGenerator; private readonly ISecuritySettings _securitySettings; + private readonly IRequestAccessor _requestAccessor; public UsersController( IGlobalSettings globalSettings, @@ -68,7 +69,8 @@ namespace Umbraco.Web.Editors IHostingEnvironment hostingEnvironment, IImageUrlGenerator imageUrlGenerator, IPublishedUrlProvider publishedUrlProvider, - ISecuritySettings securitySettings) + ISecuritySettings securitySettings, + IRequestAccessor requestAccessor) : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, shortStringHelper, umbracoMapper, publishedUrlProvider) { _mediaFileSystem = mediaFileSystem; @@ -77,6 +79,7 @@ namespace Umbraco.Web.Editors _sqlContext = sqlContext; _imageUrlGenerator = imageUrlGenerator; _securitySettings = securitySettings; + _requestAccessor = requestAccessor; } /// @@ -489,7 +492,7 @@ namespace Umbraco.Web.Editors }); // Construct full URL using configured application URL (which will fall back to request) - var applicationUri = RuntimeState.ApplicationUrl; + var applicationUri = _requestAccessor.GetApplicationUrl(); var inviteUri = new Uri(applicationUri, action); var emailSubject = Services.TextService.Localize("user/inviteEmailCopySubject", diff --git a/src/Umbraco.Web/UmbracoInjectedModule.cs b/src/Umbraco.Web/UmbracoInjectedModule.cs index 99aece5f8c..1df99ad45f 100644 --- a/src/Umbraco.Web/UmbracoInjectedModule.cs +++ b/src/Umbraco.Web/UmbracoInjectedModule.cs @@ -72,9 +72,6 @@ namespace Umbraco.Web /// private void BeginRequest(HttpContextBase httpContext) { - // ensure application url is initialized - ((RuntimeState) Current.RuntimeState).EnsureApplicationUrl(); - // do not process if client-side request if (httpContext.Request.Url.IsClientSideRequest()) return; diff --git a/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs b/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs index 9f52e52864..d009528bc7 100644 --- a/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs +++ b/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs @@ -113,11 +113,6 @@ namespace Umbraco.Web.WebApi /// internal IRuntimeState RuntimeState { get; } - /// - /// Gets the application url. - /// - protected Uri ApplicationUrl => RuntimeState.ApplicationUrl; - /// /// Gets the mapper. ///