diff --git a/src/Umbraco.Core/Constants-Web.cs b/src/Umbraco.Core/Constants-Web.cs
index 5602b99e2d..96f45cd1ba 100644
--- a/src/Umbraco.Core/Constants-Web.cs
+++ b/src/Umbraco.Core/Constants-Web.cs
@@ -49,6 +49,11 @@
/// The default authentication type used for remembering that 2FA is not needed on next login
///
public const string TwoFactorRememberBrowserCookie = "TwoFactorRememberBrowser";
+
+ public static class Mvc
+ {
+ public const string InstallArea = "UmbracoInstall";
+ }
}
}
}
diff --git a/src/Umbraco.Web.Common/Extensions/IUrlHelperExtensions.cs b/src/Umbraco.Web.Common/Extensions/IUrlHelperExtensions.cs
index 6b35563ae1..c53e13f3b9 100644
--- a/src/Umbraco.Web.Common/Extensions/IUrlHelperExtensions.cs
+++ b/src/Umbraco.Web.Common/Extensions/IUrlHelperExtensions.cs
@@ -6,6 +6,7 @@ using Umbraco.Core;
using Umbraco.Web.Common.Controllers;
using Umbraco.Extensions;
using Umbraco.Web.WebApi;
+using Microsoft.AspNetCore.Mvc.Routing;
namespace Umbraco.Extensions
{
@@ -101,30 +102,26 @@ namespace Umbraco.Extensions
if (controllerName == null) throw new ArgumentNullException(nameof(controllerName));
if (string.IsNullOrWhiteSpace(controllerName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(controllerName));
- string routeName;
if (area.IsNullOrWhiteSpace())
{
- routeName = string.Format("umbraco-{0}-{1}", "api", controllerName);
if (id == null)
{
-
- return url.RouteUrl(routeName, new { controller = controllerName, action = actionName, httproute = "" });
+ return url.Action(actionName, controllerName);
}
else
{
- return url.RouteUrl(routeName, new { controller = controllerName, action = actionName, id = id, httproute = "" });
+ return url.Action(actionName, controllerName, new { id = id });
}
}
else
{
- routeName = string.Format("umbraco-{0}-{1}-{2}", "api", area, controllerName);
if (id == null)
{
- return url.RouteUrl(routeName, new { controller = controllerName, action = actionName, httproute = "" });
+ return url.Action(actionName, controllerName, new { area = area });
}
else
{
- return url.RouteUrl(routeName, new { controller = controllerName, action = actionName, id = id, httproute = "" });
+ return url.Action(actionName, controllerName, new { area = area, id = id });
}
}
}
diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoInstallApplicationBuilderExtensions.cs b/src/Umbraco.Web.Common/Extensions/UmbracoInstallApplicationBuilderExtensions.cs
index b23519f389..fcc8cc8e30 100644
--- a/src/Umbraco.Web.Common/Extensions/UmbracoInstallApplicationBuilderExtensions.cs
+++ b/src/Umbraco.Web.Common/Extensions/UmbracoInstallApplicationBuilderExtensions.cs
@@ -27,11 +27,19 @@ namespace Umbraco.Extensions
case RuntimeLevel.Install:
case RuntimeLevel.Upgrade:
- // TODO: Fix this routing with an area
- endpoints.MapControllerRoute("Install", "/install/{controller}/{Action}", defaults: new { Area = "Install" });
+ var installPath = uriUtility.ToAbsolute(Constants.SystemDirectories.Install).EnsureEndsWith('/');
- // TODO register routing correct: Name must be like this
- endpoints.MapControllerRoute("umbraco-api-UmbracoInstall-InstallApi", "/install/api/{Action}", defaults: new { Area = "Install", Controller = "InstallApi" });
+ endpoints.MapAreaControllerRoute(
+ "umbraco-install-api",
+ Umbraco.Core.Constants.Web.Mvc.InstallArea,
+ $"{installPath}api/{{Action}}",
+ new { controller = "InstallApi" });
+
+ endpoints.MapAreaControllerRoute(
+ "umbraco-install",
+ Umbraco.Core.Constants.Web.Mvc.InstallArea,
+ $"{installPath}{{controller}}/{{Action}}",
+ new { controller = "Install", action = "Index" });
// TODO: Potentially switch this to dynamic routing so we can essentially disable/overwrite the back office routes to redirect to install,
// example https://www.strathweb.com/2019/08/dynamic-controller-routing-in-asp-net-core-3-0/
@@ -42,8 +50,8 @@ namespace Umbraco.Extensions
var uri = context.Request.GetEncodedUrl();
// redirect to install
ReportRuntime(logger, runtime.Level, "Umbraco must install or upgrade.");
- var installPath = uriUtility.ToAbsolute(Constants.SystemDirectories.Install);
- var installUrl = $"{installPath}/?redir=true&url={uri}";
+
+ var installUrl = $"{installPath}?redir=true&url={uri}";
context.Response.Redirect(installUrl, true);
return Task.CompletedTask;
});
diff --git a/src/Umbraco.Web.Common/Install/InstallApiController.cs b/src/Umbraco.Web.Common/Install/InstallApiController.cs
index ca3596e93c..2d22de730b 100644
--- a/src/Umbraco.Web.Common/Install/InstallApiController.cs
+++ b/src/Umbraco.Web.Common/Install/InstallApiController.cs
@@ -24,7 +24,7 @@ namespace Umbraco.Web.Common.Install
[TypeFilter(typeof(HttpResponseExceptionFilter))]
[TypeFilter(typeof(AngularJsonOnlyConfigurationAttribute))]
[HttpInstallAuthorize]
- [Area("Install")]
+ [Area(Umbraco.Core.Constants.Web.Mvc.InstallArea)]
public class InstallApiController : ControllerBase
{
private readonly DatabaseBuilder _databaseBuilder;
diff --git a/src/Umbraco.Web.Common/Install/InstallController.cs b/src/Umbraco.Web.Common/Install/InstallController.cs
index 07f0376697..a5e035b4d0 100644
--- a/src/Umbraco.Web.Common/Install/InstallController.cs
+++ b/src/Umbraco.Web.Common/Install/InstallController.cs
@@ -14,12 +14,10 @@ namespace Umbraco.Web.Common.Install
{
///
- /// The MVC Installation controller
+ /// The Installation controller
///
- ///
- /// NOTE: All views must have their full paths as we do not have a custom view engine for the installation views!
- ///
[InstallAuthorize]
+ [Area(Umbraco.Core.Constants.Web.Mvc.InstallArea)]
public class InstallController : Controller
{
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
@@ -72,7 +70,7 @@ namespace Umbraco.Web.Common.Install
}
// gen the install base urlAddUmbracoCore
- ViewData.SetInstallApiBaseUrl(Url.GetUmbracoApiService("GetSetup", "InstallApi", "UmbracoInstall").TrimEnd("GetSetup"));
+ ViewData.SetInstallApiBaseUrl(Url.GetUmbracoApiService("GetSetup", "InstallApi", Umbraco.Core.Constants.Web.Mvc.InstallArea).TrimEnd("GetSetup"));
// get the base umbraco folder
ViewData.SetUmbracoBaseFolder(_hostingEnvironment.ToAbsolute(_globalSettings.UmbracoPath));
@@ -81,7 +79,6 @@ namespace Umbraco.Web.Common.Install
await _installHelper.InstallStatus(false, "");
- // always ensure full path (see NOTE in the class remarks)
return View();
}
}
diff --git a/src/Umbraco.Web.UI.NetCore/Views/Install/Index.cshtml b/src/Umbraco.Web.UI.NetCore/Areas/UmbracoInstall/Views/Install/Index.cshtml
similarity index 100%
rename from src/Umbraco.Web.UI.NetCore/Views/Install/Index.cshtml
rename to src/Umbraco.Web.UI.NetCore/Areas/UmbracoInstall/Views/Install/Index.cshtml
diff --git a/src/Umbraco.Web.UI.NetCore/HomeController.cs b/src/Umbraco.Web.UI.NetCore/HomeController.cs
deleted file mode 100644
index 15d6d055d2..0000000000
--- a/src/Umbraco.Web.UI.NetCore/HomeController.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Mvc;
-
-// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
-
-namespace Umbraco.Web.UI.BackOffice
-{
- public class HomeController : Controller
- {
- // GET: //
- public IActionResult Index()
- {
- return View();
- }
- }
-}
diff --git a/src/Umbraco.Web.UI.NetCore/Umbraco.Web.UI.NetCore.csproj b/src/Umbraco.Web.UI.NetCore/Umbraco.Web.UI.NetCore.csproj
index dbb9872dc1..966cb9c86e 100644
--- a/src/Umbraco.Web.UI.NetCore/Umbraco.Web.UI.NetCore.csproj
+++ b/src/Umbraco.Web.UI.NetCore/Umbraco.Web.UI.NetCore.csproj
@@ -13,6 +13,7 @@
+
@@ -40,7 +41,7 @@
-
+
true
PreserveNewest