diff --git a/src/Umbraco.Core/Configuration/HealthChecks/TrySkipIisCustomErrorsCheck.cs b/src/Umbraco.Core/Configuration/HealthChecks/TrySkipIisCustomErrorsCheck.cs index 58172ba063..e6ec49a1e7 100644 --- a/src/Umbraco.Core/Configuration/HealthChecks/TrySkipIisCustomErrorsCheck.cs +++ b/src/Umbraco.Core/Configuration/HealthChecks/TrySkipIisCustomErrorsCheck.cs @@ -13,13 +13,13 @@ namespace Umbraco.Web.HealthCheck.Checks.Config Group = "Configuration")] public class TrySkipIisCustomErrorsCheck : AbstractConfigCheck { - private readonly IHostingEnvironment _hostingEnvironment; + private readonly Version _iisVersion; public TrySkipIisCustomErrorsCheck(ILocalizedTextService textService, IIOHelper ioHelper, ILogger logger, IHostingEnvironment hostingEnvironment) : base(textService, ioHelper, logger) { - _hostingEnvironment = hostingEnvironment; + _iisVersion = hostingEnvironment.IISVersion; } public override string FilePath => "~/Config/umbracoSettings.config"; @@ -33,7 +33,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config get { // beware! 7.5 and 7.5.0 are not the same thing! - var recommendedValue = _hostingEnvironment.IISVersion >= new Version("7.5") + var recommendedValue = _iisVersion >= new Version("7.5") ? bool.TrueString.ToLower() : bool.FalseString.ToLower(); return new List { new AcceptableConfiguration { IsRecommended = true, Value = recommendedValue } }; @@ -45,7 +45,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config get { return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckSuccessMessage", - new[] { Values.First(v => v.IsRecommended).Value, _hostingEnvironment.IISVersion.ToString() }); + new[] { Values.First(v => v.IsRecommended).Value, _iisVersion.ToString() }); } } @@ -54,7 +54,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config get { return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckErrorMessage", - new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, _hostingEnvironment.IISVersion.ToString() }); + new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, _iisVersion.ToString() }); } } @@ -63,7 +63,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config get { return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckRectifySuccessMessage", - new[] { Values.First(v => v.IsRecommended).Value, _hostingEnvironment.IISVersion.ToString() }); + new[] { Values.First(v => v.IsRecommended).Value, _iisVersion.ToString() }); } } } diff --git a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs index 1662879cf2..083a07caa4 100644 --- a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs +++ b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs @@ -11,8 +11,6 @@ namespace Umbraco.Core.Hosting string LocalTempPath { get; } string ApplicationVirtualPath { get; } - int CurrentDomainId { get; } - bool IsDebugMode { get; } /// /// Gets a value indicating whether Umbraco is hosted. diff --git a/src/Umbraco.Web.BackOffice/AspNetCore/AspNetCoreHostingEnvironment.cs b/src/Umbraco.Web.BackOffice/AspNetCore/AspNetCoreHostingEnvironment.cs index 0674702e10..942e1d3bfb 100644 --- a/src/Umbraco.Web.BackOffice/AspNetCore/AspNetCoreHostingEnvironment.cs +++ b/src/Umbraco.Web.BackOffice/AspNetCore/AspNetCoreHostingEnvironment.cs @@ -1,4 +1,3 @@ - using System; using System.IO; using Microsoft.AspNetCore.Hosting; @@ -12,6 +11,7 @@ namespace Umbraco.Web.BackOffice.AspNetCore { private readonly IHostingSettings _hostingSettings; private readonly IWebHostEnvironment _webHostEnvironment; + private string _localTempPath; public AspNetCoreHostingEnvironment(IHostingSettings hostingSettings, IWebHostEnvironment webHostEnvironment) { @@ -19,22 +19,57 @@ namespace Umbraco.Web.BackOffice.AspNetCore _webHostEnvironment = webHostEnvironment; SiteName = webHostEnvironment.ApplicationName; - ApplicationPhysicalPath = webHostEnvironment.ContentRootPath; - IsHosted = true; - ApplicationVirtualPath = "/"; //TODO how to find this, This is a server thing, not application thing. ApplicationId = AppDomain.CurrentDomain.Id.ToString(); - CurrentDomainId = AppDomain.CurrentDomain.Id; + ApplicationPhysicalPath = webHostEnvironment.ContentRootPath; + + ApplicationVirtualPath = "/"; //TODO how to find this, This is a server thing, not application thing. // IISVersion = HttpRuntime.IISVersion; + IsDebugMode = _hostingSettings.DebugMode; } public string SiteName { get; } public string ApplicationId { get; } public string ApplicationPhysicalPath { get; } - public string LocalTempPath { get; } + public string LocalTempPath + { + get + { + if (_localTempPath != null) + return _localTempPath; + + switch (_hostingSettings.LocalTempStorageLocation) + { + case LocalTempStorage.AspNetTemp: + return _localTempPath = System.IO.Path.Combine(Path.GetTempPath(),ApplicationId, "UmbracoData"); + + case LocalTempStorage.EnvironmentTemp: + + // environment temp is unique, we need a folder per site + + // use a hash + // combine site name and application id + // site name is a Guid on Cloud + // application id is eg /LM/W3SVC/123456/ROOT + // the combination is unique on one server + // and, if a site moves from worker A to B and then back to A... + // hopefully it gets a new Guid or new application id? + + var hashString = SiteName + "::" + ApplicationId; + var hash = hashString.GenerateHash(); + var siteTemp = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", hash); + + return _localTempPath = siteTemp; + + //case LocalTempStorage.Default: + //case LocalTempStorage.Unknown: + default: + return _localTempPath = MapPath("~/App_Data/TEMP"); + } + } + } public string ApplicationVirtualPath { get; } - public int CurrentDomainId { get; } - public bool IsDebugMode => _hostingSettings.DebugMode; - public bool IsHosted { get; } + public bool IsDebugMode { get; } + public bool IsHosted { get; } = true; public Version IISVersion { get; } public string MapPath(string path) => Path.Combine(_webHostEnvironment.WebRootPath, path); diff --git a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs index f9b1f1019b..7fadf9b360 100644 --- a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs +++ b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs @@ -26,12 +26,9 @@ namespace Umbraco.Web.Hosting ApplicationId = HostingEnvironment.ApplicationID; ApplicationPhysicalPath = HostingEnvironment.ApplicationPhysicalPath; ApplicationVirtualPath = HostingEnvironment.ApplicationVirtualPath; - CurrentDomainId = AppDomain.CurrentDomain.Id; IISVersion = HttpRuntime.IISVersion; } - public int CurrentDomainId { get; } - public string SiteName { get; } public string ApplicationId { get; } public string ApplicationPhysicalPath { get; }