From b242dbd6495a70067b245b0bc46c64c7ec3ba181 Mon Sep 17 00:00:00 2001 From: peggy-quartech Date: Thu, 5 Dec 2024 12:06:06 -0800 Subject: [PATCH] test --- src/Spd.Presentation.Licensing/Program.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Spd.Presentation.Licensing/Program.cs b/src/Spd.Presentation.Licensing/Program.cs index 30a6edd3d..16455ad41 100644 --- a/src/Spd.Presentation.Licensing/Program.cs +++ b/src/Spd.Presentation.Licensing/Program.cs @@ -75,15 +75,18 @@ app.UseResponseCaching(); app.UseRequestDecompression(); app.UseResponseCompression(); - app.UseStaticFiles(); - if (app.Configuration.GetValue("MaintenanceMode", false)) - { - app.MapFallbackToFile("maintenance/offline.html"); - } - else + app.Use(async (context, next) => { - app.MapFallbackToFile("index.html"); - } + var isMaintenance = builder.Configuration.GetValue("MaintenanceMode"); // Get the value from appsettings.json + if (isMaintenance && !context.Request.Path.Value.Contains("maintenance")) + { + context.Response.Redirect("/maintenance/offline.html"); + return; + } + await next(); + }); + app.UseStaticFiles(); + app.MapFallbackToFile("index.html"); app.UseRouting(); app.UseObservabilityMiddleware(); app.UseHealthChecks();