diff --git a/src/Umbraco.Configuration/Legacy/HostingSettings.cs b/src/Umbraco.Configuration/Legacy/HostingSettings.cs
index d0d09ea86f..1858e8a4a4 100644
--- a/src/Umbraco.Configuration/Legacy/HostingSettings.cs
+++ b/src/Umbraco.Configuration/Legacy/HostingSettings.cs
@@ -19,6 +19,8 @@ namespace Umbraco.Core.Configuration.Legacy
}
}
+ public string ApplicationVirtualPath => null;
+
///
/// Gets a value indicating whether umbraco is running in [debug mode].
///
diff --git a/src/Umbraco.Configuration/Models/HostingSettings.cs b/src/Umbraco.Configuration/Models/HostingSettings.cs
index 7cfc08d2d4..f0fbcf4cab 100644
--- a/src/Umbraco.Configuration/Models/HostingSettings.cs
+++ b/src/Umbraco.Configuration/Models/HostingSettings.cs
@@ -18,6 +18,8 @@ namespace Umbraco.Configuration.Models
public LocalTempStorage LocalTempStorageLocation =>
_configuration.GetValue(Prefix+"LocalTempStorage", LocalTempStorage.Default);
+ public string ApplicationVirtualPath => null;
+
///
/// Gets a value indicating whether umbraco is running in [debug mode].
///
diff --git a/src/Umbraco.Core/Configuration/GlobalSettingsExtensions.cs b/src/Umbraco.Core/Configuration/GlobalSettingsExtensions.cs
new file mode 100644
index 0000000000..a9a7f578d0
--- /dev/null
+++ b/src/Umbraco.Core/Configuration/GlobalSettingsExtensions.cs
@@ -0,0 +1,58 @@
+using System;
+using Umbraco.Core.Hosting;
+
+namespace Umbraco.Core.Configuration
+{
+ public static class GlobalSettingsExtensions
+ {
+ private static string _mvcArea;
+ private static string _backOfficePath;
+
+ ///
+ /// Returns the absolute path for the Umbraco back office
+ ///
+ ///
+ ///
+ ///
+ public static string GetBackOfficePath(this IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
+ {
+ if (_backOfficePath != null) return _backOfficePath;
+ _backOfficePath = hostingEnvironment.ToAbsolute(globalSettings.UmbracoPath);
+ return _backOfficePath;
+ }
+
+ ///
+ /// This returns the string of the MVC Area route.
+ ///
+ ///
+ /// This will return the MVC area that we will route all custom routes through like surface controllers, etc...
+ /// We will use the 'Path' (default ~/umbraco) to create it but since it cannot contain '/' and people may specify a path of ~/asdf/asdf/admin
+ /// we will convert the '/' to '-' and use that as the path. its a bit lame but will work.
+ ///
+ /// We also make sure that the virtual directory (SystemDirectories.Root) is stripped off first, otherwise we'd end up with something
+ /// like "MyVirtualDirectory-Umbraco" instead of just "Umbraco".
+ ///
+ public static string GetUmbracoMvcArea(this IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
+ {
+ if (_mvcArea != null) return _mvcArea;
+
+ _mvcArea = globalSettings.GetUmbracoMvcAreaNoCache(hostingEnvironment);
+
+ return _mvcArea;
+ }
+
+ internal static string GetUmbracoMvcAreaNoCache(this IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
+ {
+ var path = string.IsNullOrEmpty(globalSettings.UmbracoPath)
+ ? string.Empty
+ : hostingEnvironment.ToAbsolute(globalSettings.UmbracoPath);
+
+ if (path.IsNullOrWhiteSpace())
+ throw new InvalidOperationException("Cannot create an MVC Area path without the umbracoPath specified");
+
+ if (path.StartsWith(hostingEnvironment.ApplicationVirtualPath)) // beware of TrimStart, see U4-2518
+ path = path.Substring(hostingEnvironment.ApplicationVirtualPath.Length);
+ return path.TrimStart('~').TrimStart('/').Replace('/', '-').Trim().ToLower();
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Configuration/IHostingSettings.cs b/src/Umbraco.Core/Configuration/IHostingSettings.cs
index ef399177a4..48ff4f216e 100644
--- a/src/Umbraco.Core/Configuration/IHostingSettings.cs
+++ b/src/Umbraco.Core/Configuration/IHostingSettings.cs
@@ -1,11 +1,24 @@
+using Umbraco.Core.Hosting;
+
namespace Umbraco.Core.Configuration
{
public interface IHostingSettings
{
bool DebugMode { get; }
+
///
/// Gets the configuration for the location of temporary files.
///
LocalTempStorage LocalTempStorageLocation { get; }
+
+ ///
+ /// Optional property to explicitly configure the application's virtual path
+ ///
+ ///
+ /// By default this is null which will mean that the is automatically configured,
+ /// otherwise this explicitly sets it.
+ /// If set, this value must begin with a "/" and cannot end with "/".
+ ///
+ string ApplicationVirtualPath { get; }
}
}
diff --git a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
index 1ef66c66bb..0bdfe5c425 100644
--- a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
+++ b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
@@ -9,13 +9,23 @@ namespace Umbraco.Core.Hosting
string ApplicationPhysicalPath { get; }
string LocalTempPath { get; }
+
+ ///
+ /// The web application's hosted path
+ ///
+ ///
+ /// In most cases this will return "/" but if the site is hosted in a virtual directory then this will return the virtual directory's path such as "/mysite".
+ /// This value must begin with a "/" and cannot end with "/".
+ ///
string ApplicationVirtualPath { get; }
bool IsDebugMode { get; }
+
///
/// Gets a value indicating whether Umbraco is hosted.
///
bool IsHosted { get; }
+
Version IISVersion { get; }
string MapPath(string path);
diff --git a/src/Umbraco.Core/IO/IIOHelper.cs b/src/Umbraco.Core/IO/IIOHelper.cs
index dccd394817..ee36b2a96b 100644
--- a/src/Umbraco.Core/IO/IIOHelper.cs
+++ b/src/Umbraco.Core/IO/IIOHelper.cs
@@ -4,10 +4,9 @@ namespace Umbraco.Core.IO
{
public interface IIOHelper
{
-
- string BackOfficePath { get; }
-
+ // TODO: There is no need for this, we should just use Path.DirectorySeparatorChar which is cross platform, no need for an abstraction?
char DirSepChar { get; }
+
string FindFile(string virtualPath);
// TODO: This is the same as IHostingEnvironment.ToAbsolute
@@ -57,12 +56,5 @@ namespace Umbraco.Core.IO
///
string GetRelativePath(string path);
- // TODO: This is the same as IHostingEnvironment.ApplicationVirtualPath i don't think we want this
- string Root
- {
- get;
- set; //Only required for unit tests
- }
-
}
}
diff --git a/src/Umbraco.Core/IO/IOHelper.cs b/src/Umbraco.Core/IO/IOHelper.cs
index 10ef478d26..91b1d70a11 100644
--- a/src/Umbraco.Core/IO/IOHelper.cs
+++ b/src/Umbraco.Core/IO/IOHelper.cs
@@ -13,29 +13,15 @@ namespace Umbraco.Core.IO
public class IOHelper : IIOHelper
{
private readonly IHostingEnvironment _hostingEnvironment;
- private readonly IGlobalSettings _globalSettings;
public IOHelper(IHostingEnvironment hostingEnvironment, IGlobalSettings globalSettings)
{
_hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
- _globalSettings = globalSettings;
}
- public string BackOfficePath
- {
- get
- {
- var path = _globalSettings.UmbracoPath;
-
- return string.IsNullOrEmpty(path) ? string.Empty : ResolveUrl(path);
- }
- }
-
-
// static compiled regex for faster performance
//private static readonly Regex ResolveUrlPattern = new Regex("(=[\"\']?)(\\W?\\~(?:.(?![\"\']?\\s+(?:\\S+)=|[>\"\']))+.)[\"\']?", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
-
public char DirSepChar => Path.DirectorySeparatorChar;
//helper to try and match the old path to a new virtual one
@@ -44,10 +30,10 @@ namespace Umbraco.Core.IO
string retval = virtualPath;
if (virtualPath.StartsWith("~"))
- retval = virtualPath.Replace("~", Root);
+ retval = virtualPath.Replace("~", _hostingEnvironment.ApplicationVirtualPath);
- if (virtualPath.StartsWith("/") && virtualPath.StartsWith(Root) == false)
- retval = Root + "/" + virtualPath.TrimStart('/');
+ if (virtualPath.StartsWith("/") && virtualPath.StartsWith(_hostingEnvironment.ApplicationVirtualPath) == false)
+ retval = _hostingEnvironment.ApplicationVirtualPath + "/" + virtualPath.TrimStart('/');
return retval;
}
@@ -65,7 +51,7 @@ namespace Umbraco.Core.IO
try
{
if (virtualPath.StartsWith("~"))
- return Attempt.Succeed(virtualPath.Replace("~", Root).Replace("//", "/"));
+ return Attempt.Succeed(virtualPath.Replace("~", _hostingEnvironment.ApplicationVirtualPath).Replace("//", "/"));
if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
return Attempt.Succeed(virtualPath);
@@ -93,8 +79,8 @@ namespace Umbraco.Core.IO
if (_hostingEnvironment.IsHosted)
{
- var result = (String.IsNullOrEmpty(path) == false && (path.StartsWith("~") || path.StartsWith(Root)))
- ? _hostingEnvironment.MapPath(path)
+ var result = (!string.IsNullOrEmpty(path) && (path.StartsWith("~") || path.StartsWith(_hostingEnvironment.ApplicationVirtualPath)))
+ ? _hostingEnvironment.MapPath(path)
: _hostingEnvironment.MapPath("~/" + path.TrimStart('/'));
if (result != null) return result;
@@ -136,7 +122,7 @@ namespace Umbraco.Core.IO
// TODO: what's below is dirty, there are too many ways to get the root dir, etc.
// not going to fix everything today
- var mappedRoot = MapPath(Root);
+ var mappedRoot = MapPath(_hostingEnvironment.ApplicationVirtualPath);
if (filePath.StartsWith(mappedRoot) == false)
filePath = MapPath(filePath);
@@ -204,32 +190,5 @@ namespace Umbraco.Core.IO
return PathUtility.EnsurePathIsApplicationRootPrefixed(path);
}
- private string _root;
-
- ///
- /// Gets the root path of the application
- ///
- ///
- /// In most cases this will be an empty string which indicates the app is not running in a virtual directory.
- /// This is NOT a physical path.
- ///
- public string Root
- {
- get
- {
- if (_root != null) return _root;
-
- var appPath = _hostingEnvironment.ApplicationVirtualPath;
- // ReSharper disable once ConditionIsAlwaysTrueOrFalse
- if (appPath == null || appPath == "/")
- appPath = string.Empty;
-
- _root = appPath;
-
- return _root;
- }
- //Only required for unit tests
- set => _root = value;
- }
}
}
diff --git a/src/Umbraco.Core/IO/IOHelperExtensions.cs b/src/Umbraco.Core/IO/IOHelperExtensions.cs
index 39bd5e6cc9..0e35f3b87b 100644
--- a/src/Umbraco.Core/IO/IOHelperExtensions.cs
+++ b/src/Umbraco.Core/IO/IOHelperExtensions.cs
@@ -5,8 +5,6 @@ namespace Umbraco.Core.IO
{
public static class IOHelperExtensions
{
- private static string _mvcArea;
-
///
/// Tries to create a directory.
///
@@ -38,37 +36,6 @@ namespace Umbraco.Core.IO
return "umbraco-test." + Guid.NewGuid().ToString("N").Substring(0, 8);
}
- ///
- /// This returns the string of the MVC Area route.
- ///
- ///
- /// This will return the MVC area that we will route all custom routes through like surface controllers, etc...
- /// We will use the 'Path' (default ~/umbraco) to create it but since it cannot contain '/' and people may specify a path of ~/asdf/asdf/admin
- /// we will convert the '/' to '-' and use that as the path. its a bit lame but will work.
- ///
- /// We also make sure that the virtual directory (SystemDirectories.Root) is stripped off first, otherwise we'd end up with something
- /// like "MyVirtualDirectory-Umbraco" instead of just "Umbraco".
- ///
- public static string GetUmbracoMvcArea(this IIOHelper ioHelper)
- {
- if (_mvcArea != null) return _mvcArea;
-
- _mvcArea = GetUmbracoMvcAreaNoCache(ioHelper);
-
- return _mvcArea;
- }
-
- internal static string GetUmbracoMvcAreaNoCache(this IIOHelper ioHelper)
- {
- if (ioHelper.BackOfficePath.IsNullOrWhiteSpace())
- {
- throw new InvalidOperationException("Cannot create an MVC Area path without the umbracoPath specified");
- }
-
- var path = ioHelper.BackOfficePath;
- if (path.StartsWith(ioHelper.Root)) // beware of TrimStart, see U4-2518
- path = path.Substring(ioHelper.Root.Length);
- return path.TrimStart('~').TrimStart('/').Replace('/', '-').Trim().ToLower();
- }
+
}
}
diff --git a/src/Umbraco.Core/UriExtensions.cs b/src/Umbraco.Core/UriExtensions.cs
index e7be0b6500..a8aa6f8c91 100644
--- a/src/Umbraco.Core/UriExtensions.cs
+++ b/src/Umbraco.Core/UriExtensions.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using Umbraco.Composing;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
namespace Umbraco.Core
@@ -16,44 +17,42 @@ namespace Umbraco.Core
/// Checks if the current uri is a back office request
///
///
- ///
- /// The current application path or VirtualPath
- ///
- ///
- ///
+ ///
+ ///
///
///
/// There are some special routes we need to check to properly determine this:
- ///
+ ///
/// If any route has an extension in the path like .aspx = back office
- ///
+ ///
/// These are def back office:
/// /Umbraco/BackOffice = back office
/// /Umbraco/Preview = back office
/// If it's not any of the above, and there's no extension then we cannot determine if it's back office or front-end
/// so we can only assume that it is not back office. This will occur if people use an UmbracoApiController for the backoffice
/// but do not inherit from UmbracoAuthorizedApiController and do not use [IsBackOffice] attribute.
- ///
+ ///
/// These are def front-end:
/// /Umbraco/Surface = front-end
/// /Umbraco/Api = front-end
/// But if we've got this far we'll just have to assume it's front-end anyways.
- ///
+ ///
///
- internal static bool IsBackOfficeRequest(this Uri url, string applicationPath, IIOHelper ioHelper)
+ internal static bool IsBackOfficeRequest(this Uri url, IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
{
- applicationPath = applicationPath ?? string.Empty;
-
+ var applicationPath = hostingEnvironment.ApplicationVirtualPath;
+
var fullUrlPath = url.AbsolutePath.TrimStart(new[] {'/'});
var appPath = applicationPath.TrimStart(new[] {'/'});
var urlPath = fullUrlPath.TrimStart(appPath).EnsureStartsWith('/');
//check if this is in the umbraco back office
- var isUmbracoPath = urlPath.InvariantStartsWith(ioHelper.BackOfficePath.EnsureStartsWith('/').TrimStart(appPath.EnsureStartsWith('/')).EnsureStartsWith('/'));
+ var backOfficePath = globalSettings.GetBackOfficePath(hostingEnvironment);
+ var isUmbracoPath = urlPath.InvariantStartsWith(backOfficePath.EnsureStartsWith('/').TrimStart(appPath.EnsureStartsWith('/')).EnsureStartsWith('/'));
//if not, then def not back office
if (isUmbracoPath == false) return false;
- var mvcArea = ioHelper.GetUmbracoMvcArea();
+ var mvcArea = globalSettings.GetUmbracoMvcArea(hostingEnvironment);
//if its the normal /umbraco path
if (urlPath.InvariantEquals("/" + mvcArea)
|| urlPath.InvariantEquals("/" + mvcArea + "/"))
@@ -108,9 +107,9 @@ namespace Umbraco.Core
/// Checks if the current uri is an install request
///
///
- ///
+ ///
///
- internal static bool IsInstallerRequest(this Uri url, IIOHelper ioHelper)
+ internal static bool IsInstallerRequest(this Uri url, IHostingEnvironment hostingEnvironment)
{
var authority = url.GetLeftPart(UriPartial.Authority);
var afterAuthority = url.GetLeftPart(UriPartial.Query)
@@ -118,7 +117,7 @@ namespace Umbraco.Core
.TrimStart("/");
//check if this is in the umbraco back office
- return afterAuthority.InvariantStartsWith(ioHelper.ResolveUrl("~/install").TrimStart("/"));
+ return afterAuthority.InvariantStartsWith(hostingEnvironment.ToAbsolute("~/install").TrimStart("/"));
}
///
@@ -126,13 +125,15 @@ namespace Umbraco.Core
///
///
///
+ ///
///
- internal static bool IsDefaultBackOfficeRequest(this Uri url, IIOHelper ioHelper)
+ internal static bool IsDefaultBackOfficeRequest(this Uri url, IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
{
- if (url.AbsolutePath.InvariantEquals(ioHelper.BackOfficePath.TrimEnd("/"))
- || url.AbsolutePath.InvariantEquals(ioHelper.BackOfficePath.EnsureEndsWith('/'))
- || url.AbsolutePath.InvariantEquals(ioHelper.BackOfficePath.EnsureEndsWith('/') + "Default")
- || url.AbsolutePath.InvariantEquals(ioHelper.BackOfficePath.EnsureEndsWith('/') + "Default/"))
+ var backOfficePath = globalSettings.GetBackOfficePath(hostingEnvironment);
+ if (url.AbsolutePath.InvariantEquals(backOfficePath.TrimEnd("/"))
+ || url.AbsolutePath.InvariantEquals(backOfficePath.EnsureEndsWith('/'))
+ || url.AbsolutePath.InvariantEquals(backOfficePath.EnsureEndsWith('/') + "Default")
+ || url.AbsolutePath.InvariantEquals(backOfficePath.EnsureEndsWith('/') + "Default/"))
{
return true;
}
diff --git a/src/Umbraco.Infrastructure/Models/Mapping/ContentTypeMapDefinition.cs b/src/Umbraco.Infrastructure/Models/Mapping/ContentTypeMapDefinition.cs
index 59f63f4f15..2e985bef07 100644
--- a/src/Umbraco.Infrastructure/Models/Mapping/ContentTypeMapDefinition.cs
+++ b/src/Umbraco.Infrastructure/Models/Mapping/ContentTypeMapDefinition.cs
@@ -10,6 +10,7 @@ using Umbraco.Core.PropertyEditors;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Core.Services;
using Umbraco.Core.Exceptions;
+using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Strings;
@@ -28,13 +29,13 @@ namespace Umbraco.Web.Models.Mapping
private readonly IMemberTypeService _memberTypeService;
private readonly ILogger _logger;
private readonly IShortStringHelper _shortStringHelper;
- private readonly IIOHelper _ioHelper;
private readonly IGlobalSettings _globalSettings;
+ private readonly IHostingEnvironment _hostingEnvironment;
public ContentTypeMapDefinition(PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IFileService fileService,
IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService,
- ILogger logger, IShortStringHelper shortStringHelper, IIOHelper ioHelper, IGlobalSettings globalSettings)
+ ILogger logger, IShortStringHelper shortStringHelper, IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
{
_propertyEditors = propertyEditors;
_dataTypeService = dataTypeService;
@@ -44,8 +45,8 @@ namespace Umbraco.Web.Models.Mapping
_memberTypeService = memberTypeService;
_logger = logger;
_shortStringHelper = shortStringHelper;
- _ioHelper = ioHelper;
_globalSettings = globalSettings;
+ _hostingEnvironment = hostingEnvironment;
}
public void DefineMaps(UmbracoMapper mapper)
@@ -191,7 +192,7 @@ namespace Umbraco.Web.Models.Mapping
target.Icon = source.Icon;
target.IconFilePath = target.IconIsClass
? string.Empty
- : $"{_ioHelper.BackOfficePath.EnsureEndsWith("/")}images/umbraco/{source.Icon}";
+ : $"{_globalSettings.GetBackOfficePath(_hostingEnvironment).EnsureEndsWith("/")}images/umbraco/{source.Icon}";
target.Trashed = source.Trashed;
target.Id = source.Id;
@@ -204,7 +205,7 @@ namespace Umbraco.Web.Models.Mapping
target.Thumbnail = source.Thumbnail;
target.ThumbnailFilePath = target.ThumbnailIsClass
? string.Empty
- : _ioHelper.ResolveUrl("~/umbraco/images/thumbnails/" + source.Thumbnail);
+ : _hostingEnvironment.ToAbsolute("~/umbraco/images/thumbnails/" + source.Thumbnail);
target.UpdateDate = source.UpdateDate;
}
@@ -497,7 +498,7 @@ namespace Umbraco.Web.Models.Mapping
target.Icon = source.Icon;
target.IconFilePath = target.IconIsClass
? string.Empty
- : $"{_ioHelper.BackOfficePath.EnsureEndsWith("/")}images/umbraco/{source.Icon}";
+ : $"{_globalSettings.GetBackOfficePath(_hostingEnvironment).EnsureEndsWith("/")}images/umbraco/{source.Icon}";
target.Id = source.Id;
target.IsContainer = source.IsContainer;
target.IsElement = source.IsElement;
@@ -508,7 +509,7 @@ namespace Umbraco.Web.Models.Mapping
target.Thumbnail = source.Thumbnail;
target.ThumbnailFilePath = target.ThumbnailIsClass
? string.Empty
- : _ioHelper.ResolveUrl("~/umbraco/images/thumbnails/" + source.Thumbnail);
+ : _hostingEnvironment.ToAbsolute("~/umbraco/images/thumbnails/" + source.Thumbnail);
target.Udi = MapContentTypeUdi(source);
target.UpdateDate = source.UpdateDate;
@@ -540,7 +541,7 @@ namespace Umbraco.Web.Models.Mapping
target.Icon = source.Icon;
target.IconFilePath = target.IconIsClass
? string.Empty
- : $"{_ioHelper.BackOfficePath.EnsureEndsWith("/")}images/umbraco/{source.Icon}";
+ : $"{_globalSettings.GetBackOfficePath(_hostingEnvironment).EnsureEndsWith("/")}images/umbraco/{source.Icon}";
target.Id = source.Id;
target.IsContainer = source.IsContainer;
target.IsElement = source.IsElement;
@@ -551,7 +552,7 @@ namespace Umbraco.Web.Models.Mapping
target.Thumbnail = source.Thumbnail;
target.ThumbnailFilePath = target.ThumbnailIsClass
? string.Empty
- : _ioHelper.ResolveUrl("~/umbraco/images/thumbnails/" + source.Thumbnail);
+ : _hostingEnvironment.ToAbsolute("~/umbraco/images/thumbnails/" + source.Thumbnail);
target.Trashed = source.Trashed;
target.Udi = source.Udi;
}
diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs
index 1cedca96dc..92e47771a6 100644
--- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs
+++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs
@@ -231,8 +231,6 @@ namespace Umbraco.Core.Runtime
// throws if not full-trust
_umbracoBootPermissionChecker.ThrowIfNotPermissions();
- ConfigureApplicationRootPath();
-
// run handlers
RuntimeOptions.DoRuntimeEssentials(_factory);
@@ -265,13 +263,6 @@ namespace Umbraco.Core.Runtime
};
}
- protected virtual void ConfigureApplicationRootPath()
- {
- var path = GetApplicationRootPath();
- if (string.IsNullOrWhiteSpace(path) == false)
- IOHelper.Root = path;
- }
-
private bool AcquireMainDom(IMainDom mainDom, IApplicationShutdownRegistry applicationShutdownRegistry)
{
using (var timer = ProfilingLogger.DebugDuration("Acquiring MainDom.", "Acquired."))
diff --git a/src/Umbraco.Infrastructure/Trees/TreeNode.cs b/src/Umbraco.Infrastructure/Trees/TreeNode.cs
index 7d3c657207..1b6945bcdd 100644
--- a/src/Umbraco.Infrastructure/Trees/TreeNode.cs
+++ b/src/Umbraco.Infrastructure/Trees/TreeNode.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Umbraco.Composing;
using Umbraco.Core;
+using Umbraco.Core.Configuration;
using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Web.Models.Trees
@@ -112,7 +113,8 @@ namespace Umbraco.Web.Models.Trees
return Current.IOHelper.ResolveUrl("~" + Icon.TrimStart('~'));
//legacy icon path
- return string.Format("{0}images/umbraco/{1}", Current.IOHelper.BackOfficePath.EnsureEndsWith("/"), Icon);
+ var backOfficePath = Current.Configs.Global().GetUmbracoMvcArea(Current.HostingEnvironment);
+ return string.Format("{0}images/umbraco/{1}", backOfficePath.EnsureEndsWith("/"), Icon);
}
}
diff --git a/src/Umbraco.Infrastructure/WebAssets/BackOfficeJavaScriptInitializer.cs b/src/Umbraco.Infrastructure/WebAssets/BackOfficeJavaScriptInitializer.cs
index 64de289549..18279e35ba 100644
--- a/src/Umbraco.Infrastructure/WebAssets/BackOfficeJavaScriptInitializer.cs
+++ b/src/Umbraco.Infrastructure/WebAssets/BackOfficeJavaScriptInitializer.cs
@@ -2,6 +2,7 @@
using System.Text;
using System.Text.RegularExpressions;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
namespace Umbraco.Web.WebAssets
@@ -28,9 +29,9 @@ namespace Umbraco.Web.WebAssets
/// The angular module name to boot
///
///
- ///
+ ///
///
- public static string GetJavascriptInitialization(IEnumerable scripts, string angularModule, IGlobalSettings globalSettings, IIOHelper ioHelper)
+ public static string GetJavascriptInitialization(IEnumerable scripts, string angularModule, IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
{
var jarray = new StringBuilder();
jarray.AppendLine("[");
@@ -46,7 +47,7 @@ namespace Umbraco.Web.WebAssets
}
jarray.Append("]");
- return WriteScript(jarray.ToString(), ioHelper.ResolveUrl(globalSettings.UmbracoPath), angularModule);
+ return WriteScript(jarray.ToString(), hostingEnvironment.ToAbsolute(globalSettings.UmbracoPath), angularModule);
}
///
diff --git a/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs b/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs
index 612e3d6b53..fcb27f7189 100644
--- a/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs
+++ b/src/Umbraco.Infrastructure/WebAssets/BackOfficeWebAssets.cs
@@ -4,6 +4,7 @@ using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Umbraco.Core;
+using Umbraco.Core.Configuration;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Manifest;
@@ -24,19 +25,22 @@ namespace Umbraco.Web.WebAssets
private readonly IRuntimeMinifier _runtimeMinifier;
private readonly IManifestParser _parser;
- private readonly IIOHelper _ioHelper;
+ private readonly IGlobalSettings _globalSettings;
+ private readonly IHostingEnvironment _hostingEnvironment;
private readonly PropertyEditorCollection _propertyEditorCollection;
public BackOfficeWebAssets(
IRuntimeMinifier runtimeMinifier,
IManifestParser parser,
- IIOHelper ioHelper,
- PropertyEditorCollection propertyEditorCollection)
+ PropertyEditorCollection propertyEditorCollection,
+ IHostingEnvironment hostingEnvironment,
+ IGlobalSettings globalSettings)
{
_runtimeMinifier = runtimeMinifier;
_parser = parser;
- _ioHelper = ioHelper;
_propertyEditorCollection = propertyEditorCollection;
+ _hostingEnvironment = hostingEnvironment;
+ _globalSettings = globalSettings;
}
public void CreateBundles()
@@ -150,7 +154,7 @@ namespace Umbraco.Web.WebAssets
///
private string[] FormatPaths(params string[] assets)
{
- var umbracoPath = _ioHelper.GetUmbracoMvcArea();
+ var umbracoPath = _globalSettings.GetUmbracoMvcArea(_hostingEnvironment);
return assets
.Where(x => x.IsNullOrWhiteSpace() == false)
diff --git a/src/Umbraco.Infrastructure/WebAssets/RuntimeMinifierExtensions.cs b/src/Umbraco.Infrastructure/WebAssets/RuntimeMinifierExtensions.cs
index a7c9f65668..072afa5816 100644
--- a/src/Umbraco.Infrastructure/WebAssets/RuntimeMinifierExtensions.cs
+++ b/src/Umbraco.Infrastructure/WebAssets/RuntimeMinifierExtensions.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.WebAssets;
@@ -14,10 +15,10 @@ namespace Umbraco.Web.WebAssets
/// Returns the JavaScript to load the back office's assets
///
///
- public static async Task GetScriptForLoadingBackOfficeAsync(this IRuntimeMinifier minifier, IGlobalSettings globalSettings, IIOHelper ioHelper)
+ public static async Task GetScriptForLoadingBackOfficeAsync(this IRuntimeMinifier minifier, IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
{
var files = await minifier.GetAssetPathsAsync(BackOfficeWebAssets.UmbracoJsBundleName);
- var result = BackOfficeJavaScriptInitializer.GetJavascriptInitialization(files, "umbraco", globalSettings, ioHelper);
+ var result = BackOfficeJavaScriptInitializer.GetJavascriptInitialization(files, "umbraco", globalSettings, hostingEnvironment);
result += await GetStylesheetInitializationAsync(minifier);
return result;
diff --git a/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs b/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs
index eedcc498c5..1632944895 100644
--- a/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs
+++ b/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs
@@ -163,7 +163,7 @@ namespace Umbraco.Tests.Cache
new TestDefaultCultureAccessor(),
TestObjects.GetGlobalSettings(),
Mock.Of(),
- IOHelper,
+ TestHelper.GetHostingEnvironment(),
UriUtility,
httpContextAccessor,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
index af4c660112..524a939574 100644
--- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs
@@ -79,10 +79,10 @@ namespace Umbraco.Tests.Cache.PublishedCache
_umbracoContext = new UmbracoContext(
httpContextAccessor,
publishedSnapshotService.Object,
- new WebSecurity(httpContextAccessor, Mock.Of(), globalSettings, IOHelper),
+ new WebSecurity(httpContextAccessor, Mock.Of(), globalSettings, HostingEnvironment),
globalSettings,
+ HostingEnvironment,
new TestVariationContextAccessor(),
- IOHelper,
UriUtility,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
index a1f1e6a66d..327c801f5b 100644
--- a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
+++ b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs
@@ -3,6 +3,7 @@ using NUnit.Framework;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Tests.TestHelpers;
+using Umbraco.Web.Hosting;
namespace Umbraco.Tests.Configurations
{
@@ -10,20 +11,6 @@ namespace Umbraco.Tests.Configurations
[TestFixture]
public class GlobalSettingsTests : BaseWebTest
{
- private string _root;
-
- public override void SetUp()
- {
- base.SetUp();
- _root = TestHelper.IOHelper.Root;
- }
-
- public override void TearDown()
- {
- base.TearDown();
- TestHelper.IOHelper.Root = _root;
- }
-
[TestCase("~/umbraco", "/", "umbraco")]
[TestCase("~/umbraco", "/MyVirtualDir", "umbraco")]
[TestCase("~/customPath", "/MyVirtualDir/", "custompath")]
@@ -33,18 +20,15 @@ namespace Umbraco.Tests.Configurations
{
var globalSettings = SettingsForTests.GenerateMockGlobalSettings();
- var ioHelper = new IOHelper(TestHelper.GetHostingEnvironment(), globalSettings);
+ var mockHostingSettings = Mock.Get(SettingsForTests.GetDefaultHostingSettings());
+ mockHostingSettings.Setup(x => x.ApplicationVirtualPath).Returns(rootPath);
+
+ var hostingEnvironment = new AspNetHostingEnvironment(mockHostingSettings.Object);
var globalSettingsMock = Mock.Get(globalSettings);
globalSettingsMock.Setup(x => x.UmbracoPath).Returns(() => path);
- ioHelper.Root = rootPath;
- Assert.AreEqual(outcome, ioHelper.GetUmbracoMvcAreaNoCache());
+ Assert.AreEqual(outcome, globalSettingsMock.Object.GetUmbracoMvcAreaNoCache(hostingEnvironment));
}
-
-
-
-
-
}
}
diff --git a/src/Umbraco.Tests/CoreThings/UriExtensionsTests.cs b/src/Umbraco.Tests/CoreThings/UriExtensionsTests.cs
index 2fda471b70..1fe3a50d0c 100644
--- a/src/Umbraco.Tests/CoreThings/UriExtensionsTests.cs
+++ b/src/Umbraco.Tests/CoreThings/UriExtensionsTests.cs
@@ -1,28 +1,17 @@
using System;
+using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Tests.TestHelpers;
+using Umbraco.Web.Hosting;
namespace Umbraco.Tests.CoreThings
{
[TestFixture]
public class UriExtensionsTests
{
- private string _root;
-
- [SetUp]
- public void SetUp()
- {
- _root = TestHelper.IOHelper.Root;
- }
-
- [TearDown]
- public void TearDown()
- {
- TestHelper.IOHelper.Root = _root;
- }
[TestCase("http://www.domain.com/umbraco", "", true)]
[TestCase("http://www.domain.com/Umbraco/", "", true)]
@@ -45,10 +34,13 @@ namespace Umbraco.Tests.CoreThings
[TestCase("http://www.domain.com/umbraco/test/legacyAjaxCalls.ashx?some=query&blah=js", "", true)]
public void Is_Back_Office_Request(string input, string virtualPath, bool expected)
{
- var ioHelper = TestHelper.IOHelper;
- ioHelper.Root = virtualPath;
+ var globalSettings = SettingsForTests.GenerateMockGlobalSettings();
+ var mockHostingSettings = Mock.Get(SettingsForTests.GetDefaultHostingSettings());
+ mockHostingSettings.Setup(x => x.ApplicationVirtualPath).Returns(virtualPath);
+ var hostingEnvironment = new AspNetHostingEnvironment(mockHostingSettings.Object);
+
var source = new Uri(input);
- Assert.AreEqual(expected, source.IsBackOfficeRequest(virtualPath, ioHelper));
+ Assert.AreEqual(expected, source.IsBackOfficeRequest(globalSettings, hostingEnvironment));
}
[TestCase("http://www.domain.com/install", true)]
@@ -63,7 +55,7 @@ namespace Umbraco.Tests.CoreThings
public void Is_Installer_Request(string input, bool expected)
{
var source = new Uri(input);
- Assert.AreEqual(expected, source.IsInstallerRequest(TestHelper.IOHelper));
+ Assert.AreEqual(expected, source.IsInstallerRequest(TestHelper.GetHostingEnvironment()));
}
[TestCase("http://www.domain.com/foo/bar", "/", "http://www.domain.com/")]
diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs
index 756f452f71..02d380d843 100644
--- a/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs
+++ b/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs
@@ -74,10 +74,10 @@ namespace Umbraco.Tests.PublishedContent
var umbracoContext = new UmbracoContext(
httpContextAccessor,
publishedSnapshotService.Object,
- new WebSecurity(httpContextAccessor, ServiceContext.UserService, globalSettings, IOHelper),
+ new WebSecurity(httpContextAccessor, ServiceContext.UserService, globalSettings, HostingEnvironment),
globalSettings,
+ HostingEnvironment,
new TestVariationContextAccessor(),
- IOHelper,
UriUtility,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
index bc58282795..b900453a5e 100644
--- a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
+++ b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
@@ -44,7 +44,7 @@ namespace Umbraco.Tests.Routing
ShortStringHelper,
new SurfaceControllerTypeCollection(Enumerable.Empty()),
new UmbracoApiControllerTypeCollection(Enumerable.Empty()),
- IOHelper);
+ HostingEnvironment);
}
public class TestRuntime : WebRuntime
diff --git a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
index f9de3579c2..2e83427b07 100644
--- a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
+++ b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs
@@ -43,7 +43,8 @@ namespace Umbraco.Tests.Routing
new RoutableDocumentFilter(globalSettings, IOHelper),
UriUtility,
AppCaches.RequestCache,
- IOHelper
+ globalSettings,
+ HostingEnvironment
);
runtime.Level = RuntimeLevel.Run;
diff --git a/src/Umbraco.Tests/Runtimes/WebRuntimeComponentTests.cs b/src/Umbraco.Tests/Runtimes/WebRuntimeComponentTests.cs
index c03fe04a2d..42a0eeba54 100644
--- a/src/Umbraco.Tests/Runtimes/WebRuntimeComponentTests.cs
+++ b/src/Umbraco.Tests/Runtimes/WebRuntimeComponentTests.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Tests.Runtimes
{
IList engines = new List
{
- new RenderViewEngine(TestHelper.IOHelper),
+ new RenderViewEngine(TestHelper.GetHostingEnvironment()),
new PluginViewEngine()
};
@@ -32,7 +32,7 @@ namespace Umbraco.Tests.Runtimes
{
IList engines = new List
{
- new RenderViewEngine(TestHelper.IOHelper),
+ new RenderViewEngine(TestHelper.GetHostingEnvironment()),
new PluginViewEngine()
};
diff --git a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs
index 8603d901c2..0113237486 100644
--- a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs
+++ b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs
@@ -123,10 +123,10 @@ namespace Umbraco.Tests.Scoping
var umbracoContext = new UmbracoContext(
httpContextAccessor,
service,
- new WebSecurity(httpContextAccessor, ServiceContext.UserService, globalSettings, IOHelper),
+ new WebSecurity(httpContextAccessor, ServiceContext.UserService, globalSettings, HostingEnvironment),
globalSettings,
+ HostingEnvironment,
new TestVariationContextAccessor(),
- IOHelper,
UriUtility,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs b/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs
index 8b84579fec..988dfb178d 100644
--- a/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs
+++ b/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs
@@ -34,15 +34,16 @@ namespace Umbraco.Tests.Security
var umbracoContext = new UmbracoContext(
httpContextAccessor,
Mock.Of(),
- new WebSecurity(httpContextAccessor, ServiceContext.UserService, globalSettings, IOHelper), globalSettings,
+ new WebSecurity(httpContextAccessor, ServiceContext.UserService, globalSettings, HostingEnvironment),
+ globalSettings,
+ HostingEnvironment,
new TestVariationContextAccessor(),
- IOHelper,
UriUtility,
new AspNetCookieManager(httpContextAccessor));
var runtime = Mock.Of(x => x.Level == RuntimeLevel.Install);
var mgr = new BackOfficeCookieManager(
- Mock.Of(accessor => accessor.UmbracoContext == umbracoContext), runtime, IOHelper, AppCaches.RequestCache);
+ Mock.Of(accessor => accessor.UmbracoContext == umbracoContext), runtime, HostingEnvironment, globalSettings, AppCaches.RequestCache);
var result = mgr.ShouldAuthenticateRequest(Mock.Of(), new Uri("http://localhost/umbraco"));
@@ -57,15 +58,15 @@ namespace Umbraco.Tests.Security
var umbCtx = new UmbracoContext(
httpContextAccessor,
Mock.Of(),
- new WebSecurity(httpContextAccessor, ServiceContext.UserService, globalSettings, IOHelper),
+ new WebSecurity(httpContextAccessor, ServiceContext.UserService, globalSettings, HostingEnvironment),
globalSettings,
+ HostingEnvironment,
new TestVariationContextAccessor(),
- IOHelper,
UriUtility,
new AspNetCookieManager(httpContextAccessor));
var runtime = Mock.Of(x => x.Level == RuntimeLevel.Run);
- var mgr = new BackOfficeCookieManager(Mock.Of(accessor => accessor.UmbracoContext == umbCtx), runtime, IOHelper, AppCaches.RequestCache);
+ var mgr = new BackOfficeCookieManager(Mock.Of(accessor => accessor.UmbracoContext == umbCtx), runtime, HostingEnvironment, globalSettings, AppCaches.RequestCache);
var request = new Mock();
request.Setup(owinRequest => owinRequest.Uri).Returns(new Uri("http://localhost/umbraco"));
diff --git a/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs b/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs
index a39219a570..66310caea9 100644
--- a/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs
+++ b/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs
@@ -143,8 +143,8 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
publishedSnapshotService.Object,
webSecurity.Object,
globalSettings,
+ TestHelper.GetHostingEnvironment(),
new TestVariationContextAccessor(),
- TestHelper.IOHelper,
TestHelper.UriUtility,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs
index 49444f8b68..585ad6cc9e 100644
--- a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs
@@ -127,7 +127,7 @@ namespace Umbraco.Tests.TestHelpers
new TestDefaultCultureAccessor(),
globalSettings,
Mock.Of(),
- TestHelper.IOHelper,
+ TestHelper.GetHostingEnvironment(),
TestHelper.UriUtility,
httpContextAccessor,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
index 159baa5c79..1245e7d59e 100644
--- a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs
@@ -378,10 +378,10 @@ namespace Umbraco.Tests.TestHelpers
httpContextAccessor,
service,
new WebSecurity(httpContextAccessor, Factory.GetInstance(),
- Factory.GetInstance(), IOHelper),
+ Factory.GetInstance(), HostingEnvironment),
globalSettings ?? Factory.GetInstance(),
+ HostingEnvironment,
new TestVariationContextAccessor(),
- IOHelper,
UriUtility,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Tests/Testing/Objects/TestUmbracoContextFactory.cs b/src/Umbraco.Tests/Testing/Objects/TestUmbracoContextFactory.cs
index d6a1606853..cb20c56d6d 100644
--- a/src/Umbraco.Tests/Testing/Objects/TestUmbracoContextFactory.cs
+++ b/src/Umbraco.Tests/Testing/Objects/TestUmbracoContextFactory.cs
@@ -43,7 +43,7 @@ namespace Umbraco.Tests.Testing.Objects
new TestDefaultCultureAccessor(),
globalSettings,
Mock.Of(),
- TestHelper.IOHelper,
+ TestHelper.GetHostingEnvironment(),
TestHelper.UriUtility,
httpContextAccessor,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs b/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs
index 1499c5274e..c09842f730 100644
--- a/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs
+++ b/src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs
@@ -33,6 +33,7 @@ using Umbraco.Web.Features;
using Umbraco.Web.Models.ContentEditing;
using IUser = Umbraco.Core.Models.Membership.IUser;
using Umbraco.Core.Configuration.UmbracoSettings;
+using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Web.Routing;
@@ -81,6 +82,7 @@ namespace Umbraco.Tests.Web.Controllers
var usersController = new AuthenticationController(
new TestUserPasswordConfig(),
Factory.GetInstance(),
+ Factory.GetInstance(),
umbracoContextAccessor,
Factory.GetInstance(),
Factory.GetInstance(),
@@ -89,7 +91,6 @@ namespace Umbraco.Tests.Web.Controllers
Factory.GetInstance(),
Factory.GetInstance(),
Factory.GetInstance(),
- Factory.GetInstance(),
Factory.GetInstance()
);
return usersController;
diff --git a/src/Umbraco.Tests/Web/Controllers/PluginControllerAreaTests.cs b/src/Umbraco.Tests/Web/Controllers/PluginControllerAreaTests.cs
index 23131b04e6..59209f3e7d 100644
--- a/src/Umbraco.Tests/Web/Controllers/PluginControllerAreaTests.cs
+++ b/src/Umbraco.Tests/Web/Controllers/PluginControllerAreaTests.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Tests.Web.Controllers
public void Ensure_Same_Area1()
{
Assert.Throws(() =>
- new PluginControllerArea(TestObjects.GetGlobalSettings(), IOHelper,
+ new PluginControllerArea(TestObjects.GetGlobalSettings(), HostingEnvironment,
new PluginControllerMetadata[]
{
PluginController.GetMetadata(typeof(Plugin1Controller)),
@@ -27,7 +27,7 @@ namespace Umbraco.Tests.Web.Controllers
public void Ensure_Same_Area3()
{
Assert.Throws(() =>
- new PluginControllerArea(TestObjects.GetGlobalSettings(), IOHelper,
+ new PluginControllerArea(TestObjects.GetGlobalSettings(), HostingEnvironment,
new PluginControllerMetadata[]
{
PluginController.GetMetadata(typeof(Plugin1Controller)),
@@ -39,7 +39,7 @@ namespace Umbraco.Tests.Web.Controllers
[Test]
public void Ensure_Same_Area2()
{
- var area = new PluginControllerArea(TestObjects.GetGlobalSettings(), IOHelper,
+ var area = new PluginControllerArea(TestObjects.GetGlobalSettings(), HostingEnvironment,
new PluginControllerMetadata[]
{
PluginController.GetMetadata(typeof(Plugin1Controller)),
diff --git a/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs b/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs
index d6c9385aa9..563d9b80f8 100644
--- a/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs
+++ b/src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs
@@ -36,6 +36,7 @@ using Umbraco.Web.Models.ContentEditing;
using IUser = Umbraco.Core.Models.Membership.IUser;
using Umbraco.Core.Mapping;
using Umbraco.Core.Configuration.UmbracoSettings;
+using Umbraco.Core.Hosting;
using Umbraco.Web.Routing;
using Umbraco.Core.Media;
@@ -91,7 +92,7 @@ namespace Umbraco.Tests.Web.Controllers
ShortStringHelper,
Factory.GetInstance(),
Factory.GetInstance(),
- Factory.GetInstance(),
+ Factory.GetInstance(),
Factory.GetInstance(),
Factory.GetInstance(),
Factory.GetInstance()
@@ -164,7 +165,7 @@ namespace Umbraco.Tests.Web.Controllers
ShortStringHelper,
Factory.GetInstance(),
Factory.GetInstance(),
- Factory.GetInstance(),
+ Factory.GetInstance(),
Factory.GetInstance(),
Factory.GetInstance(),
Factory.GetInstance()
@@ -207,7 +208,7 @@ namespace Umbraco.Tests.Web.Controllers
ShortStringHelper,
Factory.GetInstance(),
Factory.GetInstance(),
- Factory.GetInstance(),
+ Factory.GetInstance(),
Factory.GetInstance(),
Factory.GetInstance(),
Factory.GetInstance()
@@ -285,7 +286,7 @@ namespace Umbraco.Tests.Web.Controllers
ShortStringHelper,
Factory.GetInstance(),
Factory.GetInstance(),
- Factory.GetInstance(),
+ Factory.GetInstance(),
Factory.GetInstance(),
Factory.GetInstance(),
Factory.GetInstance()
diff --git a/src/Umbraco.Tests/Web/Mvc/RenderIndexActionSelectorAttributeTests.cs b/src/Umbraco.Tests/Web/Mvc/RenderIndexActionSelectorAttributeTests.cs
index 7906047520..bd9b646872 100644
--- a/src/Umbraco.Tests/Web/Mvc/RenderIndexActionSelectorAttributeTests.cs
+++ b/src/Umbraco.Tests/Web/Mvc/RenderIndexActionSelectorAttributeTests.cs
@@ -72,7 +72,7 @@ namespace Umbraco.Tests.Web.Mvc
new TestDefaultCultureAccessor(),
globalSettings,
Mock.Of(),
- TestHelper.IOHelper,
+ TestHelper.GetHostingEnvironment(),
TestHelper.UriUtility,
httpContextAccessor,
new AspNetCookieManager(httpContextAccessor));
@@ -104,7 +104,7 @@ namespace Umbraco.Tests.Web.Mvc
new TestDefaultCultureAccessor(),
globalSettings,
Mock.Of(),
- TestHelper.IOHelper,
+ TestHelper.GetHostingEnvironment(),
TestHelper.UriUtility,
httpContextAccessor,
new AspNetCookieManager(httpContextAccessor));
@@ -136,7 +136,7 @@ namespace Umbraco.Tests.Web.Mvc
new TestDefaultCultureAccessor(),
globalSettings,
Mock.Of(),
- TestHelper.IOHelper,
+ TestHelper.GetHostingEnvironment(),
TestHelper.UriUtility,
httpContextAccessor,
new AspNetCookieManager(httpContextAccessor));
@@ -168,7 +168,7 @@ namespace Umbraco.Tests.Web.Mvc
new TestDefaultCultureAccessor(),
globalSettings,
Mock.Of(),
- TestHelper.IOHelper,
+ TestHelper.GetHostingEnvironment(),
TestHelper.UriUtility,
httpContextAccessor,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs b/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs
index 2a9b85aba5..4c222b9116 100644
--- a/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs
+++ b/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs
@@ -47,7 +47,7 @@ namespace Umbraco.Tests.Web.Mvc
new TestDefaultCultureAccessor(),
globalSettings,
Mock.Of(),
- IOHelper,
+ HostingEnvironment,
UriUtility,
httpContextAccessor,
new AspNetCookieManager(httpContextAccessor));
@@ -77,7 +77,7 @@ namespace Umbraco.Tests.Web.Mvc
new TestDefaultCultureAccessor(),
globalSettings,
Mock.Of(),
- IOHelper,
+ HostingEnvironment,
UriUtility,
httpContextAccessor,
new AspNetCookieManager(httpContextAccessor));
@@ -110,7 +110,7 @@ namespace Umbraco.Tests.Web.Mvc
new TestDefaultCultureAccessor(),
globalSettings,
Mock.Of(),
- IOHelper,
+ HostingEnvironment,
UriUtility,
httpContextAccessor,
new AspNetCookieManager(httpContextAccessor));
@@ -143,7 +143,7 @@ namespace Umbraco.Tests.Web.Mvc
new TestDefaultCultureAccessor(),
globalSettings,
Mock.Of(),
- IOHelper,
+ HostingEnvironment,
UriUtility,
httpContextAccessor,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs
index c5e9556d05..dbe45ccd29 100644
--- a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs
+++ b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs
@@ -438,10 +438,10 @@ namespace Umbraco.Tests.Web.Mvc
var ctx = new UmbracoContext(
httpContextAccessor,
_service,
- new WebSecurity(httpContextAccessor, ServiceContext.UserService, globalSettings, IOHelper),
+ new WebSecurity(httpContextAccessor, ServiceContext.UserService, globalSettings, HostingEnvironment),
globalSettings,
+ HostingEnvironment,
new TestVariationContextAccessor(),
- IOHelper,
UriUtility,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs b/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs
index 123c5d3f62..a9610c6de2 100644
--- a/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs
+++ b/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs
@@ -32,10 +32,10 @@ namespace Umbraco.Tests.Web
var umbCtx = new UmbracoContext(
httpContextAccessor,
Mock.Of(),
- new WebSecurity(httpContextAccessor, ServiceContext.UserService, TestObjects.GetGlobalSettings(), IOHelper),
+ new WebSecurity(httpContextAccessor, ServiceContext.UserService, TestObjects.GetGlobalSettings(), HostingEnvironment),
TestObjects.GetGlobalSettings(),
+ HostingEnvironment,
new TestVariationContextAccessor(),
- IOHelper,
UriUtility,
new AspNetCookieManager(httpContextAccessor));
var r1 = new RouteData();
@@ -53,10 +53,10 @@ namespace Umbraco.Tests.Web
var umbCtx = new UmbracoContext(
httpContextAccessor,
Mock.Of(),
- new WebSecurity(httpContextAccessor, ServiceContext.UserService, TestObjects.GetGlobalSettings(), IOHelper),
+ new WebSecurity(httpContextAccessor, ServiceContext.UserService, TestObjects.GetGlobalSettings(), HostingEnvironment),
TestObjects.GetGlobalSettings(),
+ HostingEnvironment,
new TestVariationContextAccessor(),
- IOHelper,
UriUtility,
new AspNetCookieManager(httpContextAccessor));
@@ -84,10 +84,10 @@ namespace Umbraco.Tests.Web
var umbCtx = new UmbracoContext(
httpContextAccessor,
Mock.Of(),
- new WebSecurity(httpContextAccessor, ServiceContext.UserService, TestObjects.GetGlobalSettings(), IOHelper),
+ new WebSecurity(httpContextAccessor, ServiceContext.UserService, TestObjects.GetGlobalSettings(), HostingEnvironment),
TestObjects.GetGlobalSettings(),
+ HostingEnvironment,
new TestVariationContextAccessor(),
- IOHelper,
UriUtility,
new AspNetCookieManager(httpContextAccessor));
diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs
index 5c65b638c5..79612fec45 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs
@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Runtime;
using Umbraco.Core.WebAssets;
@@ -14,13 +15,13 @@ namespace Umbraco.Web.BackOffice.Controllers
{
private readonly IRuntimeMinifier _runtimeMinifier;
private readonly IGlobalSettings _globalSettings;
- private readonly IIOHelper _ioHelper;
+ private readonly IHostingEnvironment _hostingEnvironment;
- public BackOfficeController(IRuntimeMinifier runtimeMinifier, IGlobalSettings globalSettings, IIOHelper ioHelper)
+ public BackOfficeController(IRuntimeMinifier runtimeMinifier, IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
{
_runtimeMinifier = runtimeMinifier;
_globalSettings = globalSettings;
- _ioHelper = ioHelper;
+ _hostingEnvironment = hostingEnvironment;
}
// GET
@@ -36,7 +37,7 @@ namespace Umbraco.Web.BackOffice.Controllers
[MinifyJavaScriptResult(Order = 0)]
public async Task Application()
{
- var result = await _runtimeMinifier.GetScriptForLoadingBackOfficeAsync(_globalSettings, _ioHelper);
+ var result = await _runtimeMinifier.GetScriptForLoadingBackOfficeAsync(_globalSettings, _hostingEnvironment);
return new JavaScriptResult(result);
}
diff --git a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs
index e22e4871c8..9344901273 100644
--- a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs
+++ b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs
@@ -91,13 +91,11 @@ namespace Umbraco.Web.Common.AspNetCore
if (!virtualPath.StartsWith("~/") && !virtualPath.StartsWith("/"))
throw new InvalidOperationException($"{nameof(virtualPath)} must start with ~/ or /");
- var root = ApplicationVirtualPath.EnsureStartsWith('/');
-
// will occur if it starts with "/"
if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
return virtualPath;
- var fullPath = root.EnsureEndsWith('/') + virtualPath.TrimStart("~/");
+ var fullPath = ApplicationVirtualPath.EnsureEndsWith('/') + virtualPath.TrimStart("~/");
return fullPath;
}
diff --git a/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml
index 8321256d0a..7984bf14f7 100644
--- a/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml
+++ b/src/Umbraco.Web.UI/Umbraco/Views/AuthorizeUpgrade.cshtml
@@ -14,7 +14,7 @@
-
+
@@ -44,9 +44,10 @@
redirectUrl = Url.Action("AuthorizeUpgrade", "BackOffice")
});
}
- @Html.BareMinimumServerVariablesScript(Url, externalLoginUrl, Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.ContentSettings, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment, Model.RuntimeSettings, Model.SecuritySettings, runtimeMinifier)
-