Maintenance page when in upgrade state (#13551)

* Added functionality to show maintenance page and fixed issues with showing custom api controllers and 404 page, when umbraco had been in install or upgrade state

* Fixed Tests

* Fixed typo

* Fixed issue with login screen redirecting to website when in upgrade state, instead of backoffice
This commit is contained in:
Bjarke Berg
2022-12-14 08:14:19 +01:00
committed by GitHub
parent fd7778320a
commit 2d564a11b9
12 changed files with 217 additions and 29 deletions

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Hosting;
@@ -28,23 +29,12 @@ public class InstallAreaRoutes : IAreaRoutes
switch (_runtime.Level)
{
case var _ when _runtime.EnableInstaller():
case RuntimeLevel.Install:
case RuntimeLevel.Upgrade:
case RuntimeLevel.Run:
endpoints.MapUmbracoRoute<InstallApiController>(installPathSegment, Constants.Web.Mvc.InstallArea, "api", includeControllerNameInRoute: false);
endpoints.MapUmbracoRoute<InstallController>(installPathSegment, Constants.Web.Mvc.InstallArea, string.Empty, includeControllerNameInRoute: false);
// register catch all because if we are in install/upgrade mode then we'll catch everything
endpoints.MapFallbackToAreaController(nameof(InstallController.Index), ControllerExtensions.GetControllerName<InstallController>(), Constants.Web.Mvc.InstallArea);
break;
case RuntimeLevel.Run:
// when we are in run mode redirect to the back office if the installer endpoint is hit
endpoints.MapGet($"{installPathSegment}/{{controller?}}/{{action?}}", context =>
{
// redirect to umbraco
context.Response.Redirect(_linkGenerator.GetBackOfficeUrl(_hostingEnvironment)!, false);
return Task.CompletedTask;
});
break;
case RuntimeLevel.BootFailed:
case RuntimeLevel.Unknown: