diff --git a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
index a7fad8cbea..1ef66c66bb 100644
--- a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
+++ b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
@@ -23,16 +23,14 @@ namespace Umbraco.Core.Hosting
/// Maps a virtual path to the application's web root
///
/// The virtual path. Must start with either ~/ or / else an exception is thrown.
- /// The absolute web root value. Must start with / else an exception is thrown.
///
///
/// This maps the virtual path syntax to the web root. For example when hosting in a virtual directory called "site" and the value "~/pages/test" is passed in, it will
- /// map to "/site/pages/test" where "/site" is the value of root.
+ /// map to "/site/pages/test" where "/site" is the value of .
///
///
/// If virtualPath does not start with ~/ or /
- /// If root does not start with /
///
- string ToAbsolute(string virtualPath, string root);
+ string ToAbsolute(string virtualPath);
}
}
diff --git a/src/Umbraco.Core/IO/IOHelper.cs b/src/Umbraco.Core/IO/IOHelper.cs
index a33195b45e..10ef478d26 100644
--- a/src/Umbraco.Core/IO/IOHelper.cs
+++ b/src/Umbraco.Core/IO/IOHelper.cs
@@ -56,8 +56,7 @@ namespace Umbraco.Core.IO
public string ResolveUrl(string virtualPath)
{
if (string.IsNullOrWhiteSpace(virtualPath)) return virtualPath;
- // TODO: This is a bit odd, the whole "Root" thing is strange, we're passing this into IHostingEnvironment, but it already should know this value in it's ApplicationVirtualPath
- return _hostingEnvironment.ToAbsolute(virtualPath, Root);
+ return _hostingEnvironment.ToAbsolute(virtualPath);
}
@@ -70,8 +69,7 @@ namespace Umbraco.Core.IO
if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
return Attempt.Succeed(virtualPath);
- // TODO: This is a bit odd, the whole "Root" thing is strange, we're passing this into IHostingEnvironment, but it already should know this value in it's ApplicationVirtualPath
- return Attempt.Succeed(_hostingEnvironment.ToAbsolute(virtualPath, Root));
+ return Attempt.Succeed(_hostingEnvironment.ToAbsolute(virtualPath));
}
catch (Exception ex)
{
diff --git a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs
index d0c703ca87..e22e4871c8 100644
--- a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs
+++ b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs
@@ -86,14 +86,13 @@ namespace Umbraco.Web.Common.AspNetCore
return Path.Combine(_webHostEnvironment.WebRootPath, newPath);
}
- // TODO: Need to take into account 'root' here, maybe not, Root probably shouldn't be a param, see notes in IOHelper that calls this, we already know ApplicationVirtualPath
- public string ToAbsolute(string virtualPath, string root)
+ public string ToAbsolute(string virtualPath)
{
if (!virtualPath.StartsWith("~/") && !virtualPath.StartsWith("/"))
throw new InvalidOperationException($"{nameof(virtualPath)} must start with ~/ or /");
- if (!root.StartsWith("/"))
- throw new InvalidOperationException($"{nameof(virtualPath)} must start with /");
+ var root = ApplicationVirtualPath.EnsureStartsWith('/');
+
// will occur if it starts with "/"
if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
return virtualPath;
diff --git a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs
index 06a61c6fe9..bf9d344e9a 100644
--- a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs
+++ b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs
@@ -41,7 +41,7 @@ namespace Umbraco.Web.Hosting
return HostingEnvironment.MapPath(path);
}
- public string ToAbsolute(string virtualPath, string root) => VirtualPathUtility.ToAbsolute(virtualPath, root.EnsureStartsWith('/'));
+ public string ToAbsolute(string virtualPath) => VirtualPathUtility.ToAbsolute(virtualPath, ApplicationVirtualPath.EnsureStartsWith('/'));
public string LocalTempPath