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:
@@ -0,0 +1,42 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Web.Common.ActionsResults;
|
||||
|
||||
namespace Umbraco.Cms.Web.Common.Controllers;
|
||||
|
||||
internal sealed class MaintenanceModeActionFilterAttribute : TypeFilterAttribute
|
||||
{
|
||||
public MaintenanceModeActionFilterAttribute() : base(typeof(MaintenanceModeActionFilter))
|
||||
{
|
||||
}
|
||||
|
||||
private sealed class MaintenanceModeActionFilter : IActionFilter
|
||||
{
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
private readonly IOptionsMonitor<GlobalSettings> _globalSettings;
|
||||
|
||||
public MaintenanceModeActionFilter(IRuntimeState runtimeState, IOptionsMonitor<GlobalSettings> globalSettings)
|
||||
{
|
||||
_runtimeState = runtimeState;
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
public void OnActionExecuting(ActionExecutingContext context)
|
||||
{
|
||||
if (_runtimeState.Level == RuntimeLevel.Upgrade && _globalSettings.CurrentValue.ShowMaintenancePageWhenInUpgradeState)
|
||||
{
|
||||
context.Result = new MaintenanceResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void OnActionExecuted(ActionExecutedContext context)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ namespace Umbraco.Cms.Web.Common.Controllers;
|
||||
/// </summary>
|
||||
[ModelBindingException]
|
||||
[PublishedRequestFilter]
|
||||
[MaintenanceModeActionFilter]
|
||||
public class RenderController : UmbracoPageController, IRenderController
|
||||
{
|
||||
private readonly ILogger<RenderController> _logger;
|
||||
|
||||
Reference in New Issue
Block a user