From 7987f13a1150818dffe78c2269f955f73f850468 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 8 Jul 2015 17:32:36 +0200 Subject: [PATCH] U4-6788 - refactor OriginalRequestUrl into UmbracoApplicationUrl and fixes merge issues. --- src/Umbraco.Core/ApplicationContext.cs | 45 +++++++-- .../UmbracoSettings/IWebRoutingSection.cs | 2 + .../UmbracoSettings/WebRoutingElement.cs | 7 +- .../Sync/ServerEnvironmentHelper.cs | 92 +++++++++---------- .../ServerEnvironmentHelperTests.cs | 78 ++++++++-------- src/Umbraco.Web/Scheduling/KeepAlive.cs | 36 +++----- .../Scheduling/ScheduledPublishing.cs | 49 +++++----- src/Umbraco.Web/UmbracoModule.cs | 58 +++++++----- .../umbraco.presentation/keepAliveService.cs | 4 +- 9 files changed, 206 insertions(+), 165 deletions(-) diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs index 382c3f29c4..c08cb0e353 100644 --- a/src/Umbraco.Core/ApplicationContext.cs +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -9,6 +9,7 @@ using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Logging; using Umbraco.Core.ObjectResolution; using Umbraco.Core.Services; +using Umbraco.Core.Sync; namespace Umbraco.Core @@ -154,17 +155,47 @@ namespace Umbraco.Core } /// - /// The original/first url that the web application executes + /// The application url. /// /// - /// we need to set the initial url in our ApplicationContext, this is so our keep alive service works and this must - /// exist on a global context because the keep alive service doesn't run in a web context. - /// we are NOT going to put a lock on this because locking will slow down the application and we don't really care - /// if two threads write to this at the exact same time during first page hit. - /// see: http://issues.umbraco.org/issue/U4-2059 + /// The application url is the url that should be used by services to talk to the application, + /// eg keep alive or scheduled publishing services. It must exist on a global context because + /// some of these services may not run within a web context. + /// The format of the application url is: + /// - has a scheme (http or https) + /// - has the SystemDirectories.Umbraco path + /// - does not end with a slash + /// It is initialized on the first request made to the server, by UmbracoModule.EnsureApplicationUrl: + /// - if umbracoSettings:settings/web.routing/@appUrl is set, use the value (new setting) + /// - if umbracoSettings:settings/scheduledTasks/@baseUrl is set, use the value (backward compatibility) + /// - otherwise, use the url of the (first) request. + /// Not locking, does not matter if several threads write to this. + /// See also issues: + /// - http://issues.umbraco.org/issue/U4-2059 + /// - http://issues.umbraco.org/issue/U4-6788 + /// - http://issues.umbraco.org/issue/U4-5728 + /// - http://issues.umbraco.org/issue/U4-5391 /// - internal string OriginalRequestUrl { get; set; } + internal string UmbracoApplicationUrl + { + get + { + // if initialized, return + if (_umbracoApplicationUrl != null) return _umbracoApplicationUrl; + // try settings + ServerEnvironmentHelper.TrySetApplicationUrlFromSettings(this, UmbracoConfig.For.UmbracoSettings()); + + // and return what we have, may be null + return _umbracoApplicationUrl; + } + set + { + _umbracoApplicationUrl = value; + } + } + + internal string _umbracoApplicationUrl; // internal for tests private bool _versionsDifferenceReported; /// diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IWebRoutingSection.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IWebRoutingSection.cs index f3d42b6904..2998fc2f78 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IWebRoutingSection.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IWebRoutingSection.cs @@ -11,6 +11,8 @@ bool DisableFindContentByIdPath { get; } string UrlProviderMode { get; } + + string UmbracoApplicationUrl { get; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs index f5b71eb2c7..1ed9bc034c 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs @@ -30,8 +30,13 @@ namespace Umbraco.Core.Configuration.UmbracoSettings [ConfigurationProperty("urlProviderMode", DefaultValue = "AutoLegacy")] public string UrlProviderMode { - get { return (string)base["urlProviderMode"]; } + get { return (string) base["urlProviderMode"]; } } + [ConfigurationProperty("umbracoApplicationUrl", DefaultValue = null)] + public string UmbracoApplicationUrl + { + get { return (string)base["umbracoApplicationUrl"]; } + } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Sync/ServerEnvironmentHelper.cs b/src/Umbraco.Core/Sync/ServerEnvironmentHelper.cs index 1d5ee7855a..120326e3e2 100644 --- a/src/Umbraco.Core/Sync/ServerEnvironmentHelper.cs +++ b/src/Umbraco.Core/Sync/ServerEnvironmentHelper.cs @@ -1,10 +1,9 @@ -using System; using System.Linq; using System.Web; -using System.Xml; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.IO; +using Umbraco.Core.Logging; namespace Umbraco.Core.Sync { @@ -13,58 +12,73 @@ namespace Umbraco.Core.Sync /// internal static class ServerEnvironmentHelper { - /// - /// Returns the current umbraco base url for the current server depending on it's environment - /// status. This will attempt to determine the internal umbraco base url that can be used by the current - /// server to send a request to itself if it is in a load balanced environment. - /// - /// The full base url including schema (i.e. http://myserver:80/umbraco ) - or null if the url - /// cannot be determined at the moment (usually because the first request has not properly completed yet). - public static string GetCurrentServerUmbracoBaseUrl(ApplicationContext appContext, IUmbracoSettingsSection settings) + public static void TrySetApplicationUrlFromSettings(ApplicationContext appContext, IUmbracoSettingsSection settings) { + // try umbracoSettings:settings/web.routing/@umbracoApplicationUrl + // which is assumed to: + // - end with SystemDirectories.Umbraco + // - contain a scheme + // - end or not with a slash, it will be taken care of + // eg "http://www.mysite.com/umbraco" + var url = settings.WebRouting.UmbracoApplicationUrl; + if (url.IsNullOrWhiteSpace() == false) + { + appContext.UmbracoApplicationUrl = url.TrimEnd('/'); + LogHelper.Info("ApplicationUrl: " + appContext.UmbracoApplicationUrl + " (using web.routing/@umbracoApplicationUrl)"); + return; + } + + // try umbracoSettings:settings/scheduledTasks/@baseUrl + // which is assumed to: + // - end with SystemDirectories.Umbraco + // - NOT contain any scheme (because, legacy) + // - end or not with a slash, it will be taken care of + // eg "mysite.com/umbraco" + url = settings.ScheduledTasks.BaseUrl; + if (url.IsNullOrWhiteSpace() == false) + { + var ssl = GlobalSettings.UseSSL ? "s" : ""; + url = "http" + ssl + "://" + url; + appContext.UmbracoApplicationUrl = url.TrimEnd('/'); + LogHelper.Info("ApplicationUrl: " + appContext.UmbracoApplicationUrl + " (using scheduledTasks/@baseUrl)"); + return; + } + + // try servers var status = GetStatus(settings); - if (status == CurrentServerEnvironmentStatus.Single) - { - // single install, return null if no config/original url, else use config/original url as base - // use http or https as appropriate - return GetBaseUrl(appContext, settings); - } + return; + // no server, nothing we can do var servers = settings.DistributedCall.Servers.ToArray(); + if (servers.Length == 0) + return; - if (servers.Any() == false) - { - // cannot be determined, return null if no config/original url, else use config/original url as base - // use http or https as appropriate - return GetBaseUrl(appContext, settings); - } - + // we have servers, look for this server foreach (var server in servers) { var appId = server.AppId; var serverName = server.ServerName; + // skip if no data if (appId.IsNullOrWhiteSpace() && serverName.IsNullOrWhiteSpace()) - { continue; - } + // if this server, build and return the url if ((appId.IsNullOrWhiteSpace() == false && appId.Trim().InvariantEquals(HttpRuntime.AppDomainAppId)) || (serverName.IsNullOrWhiteSpace() == false && serverName.Trim().InvariantEquals(NetworkHelper.MachineName))) { - //match by appId or computer name! return the url configured - return string.Format("{0}://{1}:{2}/{3}", + // match by appId or computer name, return the url configured + url = string.Format("{0}://{1}:{2}/{3}", server.ForceProtocol.IsNullOrWhiteSpace() ? "http" : server.ForceProtocol, server.ServerAddress, server.ForcePortnumber.IsNullOrWhiteSpace() ? "80" : server.ForcePortnumber, IOHelper.ResolveUrl(SystemDirectories.Umbraco).TrimStart('/')); + + appContext.UmbracoApplicationUrl = url.TrimEnd('/'); + LogHelper.Info("ApplicationUrl: " + appContext.UmbracoApplicationUrl + " (using distributedCall/servers)"); } } - - // cannot be determined, return null if no config/original url, else use config/original url as base - // use http or https as appropriate - return GetBaseUrl(appContext, settings); } /// @@ -113,21 +127,5 @@ namespace Umbraco.Core.Sync return CurrentServerEnvironmentStatus.Slave; } - - private static string GetBaseUrl(ApplicationContext appContext, IUmbracoSettingsSection settings) - { - return ( - // is config empty? - settings.ScheduledTasks.BaseUrl.IsNullOrWhiteSpace() - // is the orig req empty? - ? appContext.OriginalRequestUrl.IsNullOrWhiteSpace() - // we've got nothing - ? null - //the orig req url is not null, use that - : string.Format("http{0}://{1}", GlobalSettings.UseSSL ? "s" : "", appContext.OriginalRequestUrl) - // the config has been specified, use that - : string.Format("http{0}://{1}", GlobalSettings.UseSSL ? "s" : "", settings.ScheduledTasks.BaseUrl)) - .EnsureEndsWith('/'); - } } } \ No newline at end of file diff --git a/src/Umbraco.Tests/ServerEnvironmentHelperTests.cs b/src/Umbraco.Tests/ServerEnvironmentHelperTests.cs index 237c6cb17d..39f8b71eb3 100644 --- a/src/Umbraco.Tests/ServerEnvironmentHelperTests.cs +++ b/src/Umbraco.Tests/ServerEnvironmentHelperTests.cs @@ -1,92 +1,98 @@ using System.Configuration; +using System.IO; using System.Linq; using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Configuration.UmbracoSettings; +using Umbraco.Core.Logging; +using Umbraco.Core.Profiling; using Umbraco.Core.Sync; +using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests { [TestFixture] public class ServerEnvironmentHelperTests { + + // note: in tests, read appContext._umbracoApplicationUrl and not the property, + // because reading the property does run some code, as long as the field is null. + [Test] - public void Get_Base_Url_Single_Server_Orig_Request_Url_No_SSL() + public void SetApplicationUrlWhenNoSettings() { var appContext = new ApplicationContext(null) { - OriginalRequestUrl = "test.com" + UmbracoApplicationUrl = null // NOT set }; - ConfigurationManager.AppSettings.Set("umbracoUseSSL", "false"); + ConfigurationManager.AppSettings.Set("umbracoUseSSL", "true"); // does not make a diff here - var result = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl( - appContext, - Mock.Of( - section => - section.DistributedCall == Mock.Of(callSection => callSection.Servers == Enumerable.Empty()) - && section.ScheduledTasks == Mock.Of())); - - - Assert.AreEqual("http://test.com/", result); - } - - [Test] - public void Get_Base_Url_Single_Server_Orig_Request_Url_With_SSL() - { - var appContext = new ApplicationContext(null) - { - OriginalRequestUrl = "test.com" - }; - - ConfigurationManager.AppSettings.Set("umbracoUseSSL", "true"); - - var result = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl( - appContext, + ServerEnvironmentHelper.TrySetApplicationUrlFromSettings(appContext, Mock.Of( section => section.DistributedCall == Mock.Of(callSection => callSection.Servers == Enumerable.Empty()) + && section.WebRouting == Mock.Of(wrSection => wrSection.UmbracoApplicationUrl == (string) null) && section.ScheduledTasks == Mock.Of())); - Assert.AreEqual("https://test.com/", result); + // still NOT set + Assert.IsNull(appContext._umbracoApplicationUrl); } [Test] - public void Get_Base_Url_Single_Server_Via_Config_Url_No_SSL() + public void SetApplicationUrlFromDcSettingsNoSsl() { var appContext = new ApplicationContext(null); ConfigurationManager.AppSettings.Set("umbracoUseSSL", "false"); - var result = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl( - appContext, + ServerEnvironmentHelper.TrySetApplicationUrlFromSettings(appContext, Mock.Of( section => section.DistributedCall == Mock.Of(callSection => callSection.Servers == Enumerable.Empty()) - && section.ScheduledTasks == Mock.Of(tasksSection => tasksSection.BaseUrl == "mycoolhost.com/hello/world"))); + && section.WebRouting == Mock.Of(wrSection => wrSection.UmbracoApplicationUrl == (string) null) + && section.ScheduledTasks == Mock.Of(tasksSection => tasksSection.BaseUrl == "mycoolhost.com/hello/world/"))); - Assert.AreEqual("http://mycoolhost.com/hello/world/", result); + Assert.AreEqual("http://mycoolhost.com/hello/world", appContext._umbracoApplicationUrl); } [Test] - public void Get_Base_Url_Single_Server_Via_Config_Url_With_SSL() + public void SetApplicationUrlFromDcSettingsSsl() { var appContext = new ApplicationContext(null); ConfigurationManager.AppSettings.Set("umbracoUseSSL", "true"); - var result = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl( - appContext, + ServerEnvironmentHelper.TrySetApplicationUrlFromSettings(appContext, Mock.Of( section => section.DistributedCall == Mock.Of(callSection => callSection.Servers == Enumerable.Empty()) + && section.WebRouting == Mock.Of(wrSection => wrSection.UmbracoApplicationUrl == (string) null) && section.ScheduledTasks == Mock.Of(tasksSection => tasksSection.BaseUrl == "mycoolhost.com/hello/world"))); - Assert.AreEqual("https://mycoolhost.com/hello/world/", result); + Assert.AreEqual("https://mycoolhost.com/hello/world", appContext._umbracoApplicationUrl); + } + + [Test] + public void SetApplicationUrlFromWrSettingsSsl() + { + var appContext = new ApplicationContext(null); + + ConfigurationManager.AppSettings.Set("umbracoUseSSL", "true"); // does not make a diff here + + ServerEnvironmentHelper.TrySetApplicationUrlFromSettings(appContext, + Mock.Of( + section => + section.DistributedCall == Mock.Of(callSection => callSection.Servers == Enumerable.Empty()) + && section.WebRouting == Mock.Of(wrSection => wrSection.UmbracoApplicationUrl == "httpx://whatever.com/hello/world/") + && section.ScheduledTasks == Mock.Of(tasksSection => tasksSection.BaseUrl == "mycoolhost.com/hello/world"))); + + + Assert.AreEqual("httpx://whatever.com/hello/world", appContext._umbracoApplicationUrl); } } } \ No newline at end of file diff --git a/src/Umbraco.Web/Scheduling/KeepAlive.cs b/src/Umbraco.Web/Scheduling/KeepAlive.cs index c1b43b57c6..a47f8aa72c 100644 --- a/src/Umbraco.Web/Scheduling/KeepAlive.cs +++ b/src/Umbraco.Web/Scheduling/KeepAlive.cs @@ -1,10 +1,8 @@ using System; using System.Net; using Umbraco.Core; -using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Logging; -using Umbraco.Core.Sync; namespace Umbraco.Web.Scheduling { @@ -13,32 +11,28 @@ namespace Umbraco.Web.Scheduling public static void Start(ApplicationContext appContext, IUmbracoSettingsSection settings) { using (DisposableTimer.DebugDuration(() => "Keep alive executing", () => "Keep alive complete")) - { - var umbracoBaseUrl = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl( - appContext, - settings); - - if (string.IsNullOrWhiteSpace(umbracoBaseUrl)) + { + var umbracoAppUrl = appContext.UmbracoApplicationUrl; + if (umbracoAppUrl.IsNullOrWhiteSpace()) { LogHelper.Warn("No url for service (yet), skip."); + return; } - else - { - var url = string.Format("{0}ping.aspx", umbracoBaseUrl.EnsureEndsWith('/')); - try + var url = umbracoAppUrl + "/ping.aspx"; + + try + { + using (var wc = new WebClient()) { - using (var wc = new WebClient()) - { - wc.DownloadString(url); - } + wc.DownloadString(url); } - catch (Exception ee) - { - LogHelper.Error( - string.Format("Error in ping. The base url used in the request was: {0}, see http://our.umbraco.org/documentation/Using-Umbraco/Config-files/umbracoSettings/#ScheduledTasks documentation for details on setting a baseUrl if this is in error", umbracoBaseUrl) + } + catch (Exception ee) + { + LogHelper.Error( + string.Format("Error in ping. The base url used in the request was: {0}, see http://our.umbraco.org/documentation/Using-Umbraco/Config-files/umbracoSettings/#ScheduledTasks documentation for details on setting a baseUrl if this is in error", umbracoAppUrl) , ee); - } } } diff --git a/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs b/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs index 0f7cb8c205..d1dc8d1935 100644 --- a/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs +++ b/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs @@ -58,44 +58,41 @@ namespace Umbraco.Web.Scheduling _isPublishingRunning = true; - var umbracoBaseUrl = ServerEnvironmentHelper.GetCurrentServerUmbracoBaseUrl(_appContext, _settings); + var umbracoAppUrl = _appContext.UmbracoApplicationUrl; + if (umbracoAppUrl.IsNullOrWhiteSpace()) + { + LogHelper.Warn("No url for service (yet), skip."); + return; + } try { - - if (string.IsNullOrWhiteSpace(umbracoBaseUrl)) + var url = umbracoAppUrl + "/RestServices/ScheduledPublish/Index"; + using (var wc = new HttpClient()) { - LogHelper.Warn("No url for service (yet), skip."); - } - else - { - var url = string.Format("{0}RestServices/ScheduledPublish/Index", umbracoBaseUrl.EnsureEndsWith('/')); - using (var wc = new HttpClient()) + var request = new HttpRequestMessage() { - var request = new HttpRequestMessage() - { - RequestUri = new Uri(url), - Method = HttpMethod.Post, - Content = new StringContent(string.Empty) - }; - //pass custom the authorization header - request.Headers.Authorization = AdminTokenAuthorizeAttribute.GetAuthenticationHeaderValue(_appContext); + RequestUri = new Uri(url), + Method = HttpMethod.Post, + Content = new StringContent(string.Empty) + }; + //pass custom the authorization header + request.Headers.Authorization = AdminTokenAuthorizeAttribute.GetAuthenticationHeaderValue(_appContext); - try - { - var result = await wc.SendAsync(request, token); - } - catch (Exception ex) - { - LogHelper.Error("An error occurred calling scheduled publish url", ex); - } + try + { + var result = await wc.SendAsync(request, token); + } + catch (Exception ex) + { + LogHelper.Error("An error occurred calling scheduled publish url", ex); } } } catch (Exception ee) { LogHelper.Error( - string.Format("An error occurred with the scheduled publishing. The base url used in the request was: {0}, see http://our.umbraco.org/documentation/Using-Umbraco/Config-files/umbracoSettings/#ScheduledTasks documentation for details on setting a baseUrl if this is in error", umbracoBaseUrl) + string.Format("An error occurred with the scheduled publishing. The base url used in the request was: {0}, see http://our.umbraco.org/documentation/Using-Umbraco/Config-files/umbracoSettings/#ScheduledTasks documentation for details on setting a baseUrl if this is in error", umbracoAppUrl) , ee); } finally diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs index 6efe4d4d6a..fd75430ec0 100644 --- a/src/Umbraco.Web/UmbracoModule.cs +++ b/src/Umbraco.Web/UmbracoModule.cs @@ -36,37 +36,47 @@ namespace Umbraco.Web { #region HttpModule event handlers + private static void EnsureApplicationUrl(HttpRequestBase request) + { + var appctx = ApplicationContext.Current; + + // already initialized = ok + // note that getting ApplicationUrl will ALSO try the various settings + if (appctx.UmbracoApplicationUrl.IsNullOrWhiteSpace() == false) return; + + // so if we reach that point, nothing was configured + // use the current request as application url + + // if (HTTP and SSL not required) or (HTTPS and SSL required), + // use ports from request + // otherwise, + // if non-standard ports used, + // user may need to set baseUrl manually per + // http://our.umbraco.org/documentation/Using-Umbraco/Config-files/umbracoSettings/#ScheduledTasks + // TODO update the doc, prefer web.routing/@appUrl to scheduledTasks/@baseUrl + var port = (request.IsSecureConnection == false && GlobalSettings.UseSSL == false) + || (request.IsSecureConnection && GlobalSettings.UseSSL) + ? ":" + request.ServerVariables["SERVER_PORT"] + : ""; + + var ssl = GlobalSettings.UseSSL ? "s" : ""; // force, whatever the first request + var url = "http" + ssl + "://" + request.ServerVariables["SERVER_NAME"] + port + IOHelper.ResolveUrl(SystemDirectories.Umbraco); + + appctx.UmbracoApplicationUrl = UriUtility.TrimPathEndSlash(url); + LogHelper.Info("ApplicationUrl: " + appctx.UmbracoApplicationUrl + " (UmbracoModule request)"); + } + + /// /// Begins to process a request. /// /// static void BeginRequest(HttpContextBase httpContext) { + // ensure application url is initialized + EnsureApplicationUrl(httpContext.Request); - //we need to set the initial url in our ApplicationContext, this is so our keep alive service works and this must - //exist on a global context because the keep alive service doesn't run in a web context. - //we are NOT going to put a lock on this because locking will slow down the application and we don't really care - //if two threads write to this at the exact same time during first page hit. - //see: http://issues.umbraco.org/issue/U4-2059 - if (ApplicationContext.Current.OriginalRequestUrl.IsNullOrWhiteSpace()) - { - // If (HTTP and SSL not required) or (HTTPS and SSL required), use ports from request to configure OriginalRequestUrl. - // Otherwise, user may need to set baseUrl manually per http://our.umbraco.org/documentation/Using-Umbraco/Config-files/umbracoSettings/#ScheduledTasks if non-standard ports used. - if ((!httpContext.Request.IsSecureConnection && !GlobalSettings.UseSSL) || (httpContext.Request.IsSecureConnection && GlobalSettings.UseSSL)) - { - // Use port from request. - ApplicationContext.Current.OriginalRequestUrl = string.Format("{0}:{1}{2}", httpContext.Request.ServerVariables["SERVER_NAME"], httpContext.Request.ServerVariables["SERVER_PORT"], IOHelper.ResolveUrl(SystemDirectories.Umbraco)); - } - else - { - // Omit port entirely. - ApplicationContext.Current.OriginalRequestUrl = string.Format("{0}{1}", httpContext.Request.ServerVariables["SERVER_NAME"], IOHelper.ResolveUrl(SystemDirectories.Umbraco)); - } - - LogHelper.Info("Setting OriginalRequestUrl: " + ApplicationContext.Current.OriginalRequestUrl); - } - - // do not process if client-side request + // do not process if client-side request if (httpContext.Request.Url.IsClientSideRequest()) return; diff --git a/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs b/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs index 6d80d8bedd..abc3425f3f 100644 --- a/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs +++ b/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs @@ -18,9 +18,7 @@ namespace umbraco.presentation var appContext = (ApplicationContext) sender; - //TODO: This won't always work, in load balanced scenarios ping will not work because - // this original request url will be public and not internal to the server. - var url = string.Format("http://{0}/ping.aspx", appContext.OriginalRequestUrl); + var url = appContext.UmbracoApplicationUrl + "/ping.aspx"; try { using (var wc = new WebClient())