diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index afb7cd3a..6e871e06 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -19,6 +19,11 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: '10.0.x'
+ - name: Raise file watcher limits
+ # The test hosts create a Razor file watcher per static asset, and the default limit of 128 inotify instances
+ # is reached when several hosts run in parallel.
+ if: runner.os == 'Linux'
+ run: sudo sysctl -w fs.inotify.max_user_instances=1024 fs.inotify.max_user_watches=524288
- name: Restore Six Labors license
shell: bash
run: printf '%s\n' "${{ secrets.SIXLABORS_LICENSE_KEY }}" > src/Lumina.Domain/sixlabors.lic
diff --git a/docs/manual/themes/index.md b/docs/manual/themes/index.md
index 8b0e5c78..8e7bb20f 100644
--- a/docs/manual/themes/index.md
+++ b/docs/manual/themes/index.md
@@ -84,7 +84,9 @@ The manifest is a small JSON object:
### Templates
-Templates use a small, Mustache-style syntax: `{{name}}` prints a value, escaped; `{{{name}}}` or `{{&name}}` prints it raw; `{{#name}}...{{/name}}` repeats or shows a section; `{{^name}}...{{/name}}` shows a section when a value is absent. A theme provides a layout that wraps every page, a navigation menu, an optional 404 page, page templates for the pages it wants to restyle, and optionally templates for the file system browser component.
+Templates use a small, Mustache-style syntax: `{{name}}` prints a value, escaped; `{{{name}}}` or `{{&name}}` prints it raw; `{{#name}}...{{/name}}` repeats or shows a section; `{{^name}}...{{/name}}` shows a section when a value is absent. A theme provides a layout that wraps every page, a navigation menu, a server unreachable banner, an optional 404 page, page templates for the pages it wants to restyle, and optionally templates for the file system browser component.
+
+The server unreachable banner is the strip that appears at the bottom of the window while Lumina cannot reach its server. A theme renders it from its own `shared/server-unreachable-banner` template, or from the built-in fallback when it does not provide one, and the layout places it through the `serverUnreachableBanner` field. The theme owns the markup, the placement, the position, the size, the background and everything else about the banner; it only has to keep the `data-server-unreachable-banner` hook on its root element and hide and show that element with the `is-visible` class. The [theming guide](../../technical/theming/Theming.md) describes the message field, the fallback markup and the rest of the contract.
A page is matched to a template by a key that mirrors the page's path, so the books page looks for `templates/library/written-content-library/book-library/books/index.html`, or a template at a parent scope when the exact one is missing. When a theme has no template for a page, the application renders that page itself with its own built-in view, so a theme never has to cover everything.
diff --git a/docs/manual/using-lumina/index.md b/docs/manual/using-lumina/index.md
index 47f9ec6b..2231eb22 100644
--- a/docs/manual/using-lumina/index.md
+++ b/docs/manual/using-lumina/index.md
@@ -25,6 +25,8 @@ The header menu rearranges itself depending on who you are. Everyone sees a site
The home page is your catalogue: a grid of the libraries you are allowed to see, each shown as a card with its cover when it has one. Selecting a card opens that library's browsing page. Some library types do not have a browsing page yet, and their cards appear as plain panels rather than links.
+When the server cannot be reached, Lumina keeps the page you asked for and shows a red banner along the bottom. The banner belongs to the active theme, so its position, size and look can differ between themes.
+
## Your account
Accounts are local to your Lumina server. From the account section you can:
diff --git a/docs/technical/theming/Theming.md b/docs/technical/theming/Theming.md
index 1401a625..3f009f77 100644
--- a/docs/technical/theming/Theming.md
+++ b/docs/technical/theming/Theming.md
@@ -13,6 +13,7 @@ The web client of Lumina is a themed shell: every page is rendered inside the te
- [Safety Limits](#safety-limits)
- [Template Resolution](#template-resolution)
- [The Layout Template (shared/layout)](#the-layout-template-sharedlayout)
+ - [The Server Unreachable Banner](#the-server-unreachable-banner)
- [The Audio Player Bar](#the-audio-player-bar)
- [The VU Meter](#the-vu-meter)
- [Play Affordances on the Music Pages](#play-affordances-on-the-music-pages)
@@ -170,6 +171,7 @@ Known page keys:
| --- | --- |
| `shared/layout` | The layout that wraps the shell of every page. |
| `shared/nav-menu` | The navigation menu of the theme. |
+| `shared/server-unreachable-banner` | The banner shown while the server is unreachable. |
| `shared/not-found` | The 404 page. |
| `shared/audio-player` | The audio player bar shell. |
| `shared/audio-player/queue-item` | The queue item of the audio player bar. |
@@ -196,6 +198,7 @@ Every page is rendered inside the layout template. The layout receives a model w
| `nav` | The fully rendered navigation menu HTML. |
| `content` | The fully rendered content section of the page. |
| `audioPlayer` | The rendered audio player when the user is authenticated, empty otherwise. |
+| `serverUnreachableBanner` | The rendered server unreachable banner, placed by the layout. |
| `appScripts` | The global scripts of the application. |
| `scripts` | The rendered script section of the page. |
| `mainStyle` | An inline style for the main content area, `bottom: 0px;` when the user is not authenticated and empty otherwise. |
@@ -213,6 +216,7 @@ The layout template of the bundled theme shows the intended shape:
+ {{&serverUnreachableBanner}}
{{&nav}}
@@ -239,6 +243,44 @@ The layout template of the bundled theme shows the intended shape:
The rendered page content, navigation and scripts are inserted unescaped with `{{&...}}`, because they are trusted application HTML. The layout is best effort: when the theme cannot be loaded or rendered, the application falls back to its built-in layout, so a broken theme never takes the whole site down.
+### The Server Unreachable Banner
+
+The server unreachable banner is a theme component, rendered from the `shared/server-unreachable-banner` template and placed by the layout through its `serverUnreachableBanner` field:
+
+```html
+
+ {{&serverUnreachableBanner}}
+ ...
+
+```
+
+The template receives this model:
+
+| Field | Content |
+| --- | --- |
+| `message` | The localized message that tells the user that the server is unreachable. |
+
+The fallback template shows the shape a theme should keep:
+
+```html
+
+ {{message}}
+
+```
+
+The application fallback stylesheet gives the text a slow opacity pulse through the `server-unreachable-banner-text` class, and disables it when the user asks for reduced motion. A theme can keep that class and animation, override the animation, or render its own wrapper and animate it instead.
+
+The root element of the template must carry the `data-server-unreachable-banner` hook. It should be hidden while the `is-visible` class is absent and shown while that class is present; the global script only adds and removes that class. The theme owns the markup, the placement in the layout, the position, the size, the background, including background images and extra child elements, and every other visual aspect.
+
+When the theme does not provide the template, the application renders its own fallback markup with the `server-unreachable-banner` class. The application fallback stylesheet hides it by default and fixes it to the bottom edge of the viewport, full width, with a red background and white text, and it does not block pointer interaction with the page. A theme that uses the fallback class can restyle it directly or through these custom properties:
+
+| Custom property | Default | Meaning |
+| --- | --- | --- |
+| `--server-unreachable-background-color` | `#c62828` | The background color of the banner. |
+| `--server-unreachable-text-color` | `#ffffff` | The text color of the banner. |
+
+The banner is shown while the application health probe cannot reach the API, while an API call of the page fails before the server answers (a network failure or a timeout, reported through the `api` source of the global script), and while a SignalR connection of the page is lost. A successful health probe only clears the probe source and the API-call source, so a disconnected SignalR hub keeps the banner visible until that connection reconnects. Because the element is part of the layout, it stays in the page across the AJAX navigation that swaps the content section.
+
### The Audio Player Bar
Every authenticated page renders the audio player bar through the `audioPlayer` field of the layout model. The bar starts hidden, and the global audio player script shows it when playback starts, expands it and hides it again. The markup comes from the `shared/audio-player` template of the active theme; when the theme does not provide that template, the application renders its own fallback markup, so the player always has a bar to bind to.
diff --git a/src/Lumina.Presentation.Api/Core/Themes/Bundled/editorial-paper.zip b/src/Lumina.Presentation.Api/Core/Themes/Bundled/editorial-paper.zip
index 2cedc916..fc164c3c 100644
Binary files a/src/Lumina.Presentation.Api/Core/Themes/Bundled/editorial-paper.zip and b/src/Lumina.Presentation.Api/Core/Themes/Bundled/editorial-paper.zip differ
diff --git a/src/Lumina.Presentation.Api/Core/Themes/Bundled/lumina-default.zip b/src/Lumina.Presentation.Api/Core/Themes/Bundled/lumina-default.zip
index 84756761..188876ab 100644
Binary files a/src/Lumina.Presentation.Api/Core/Themes/Bundled/lumina-default.zip and b/src/Lumina.Presentation.Api/Core/Themes/Bundled/lumina-default.zip differ
diff --git a/src/Lumina.Presentation.Web/Common/Authorization/AuthorizationService.cs b/src/Lumina.Presentation.Web/Common/Authorization/AuthorizationService.cs
index 0237af63..3a804f20 100644
--- a/src/Lumina.Presentation.Web/Common/Authorization/AuthorizationService.cs
+++ b/src/Lumina.Presentation.Web/Common/Authorization/AuthorizationService.cs
@@ -1,10 +1,14 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Enums.Authorization;
+using Lumina.Presentation.Web.Common.Exceptions;
+using Lumina.Presentation.Web.Common.Http;
using Lumina.Presentation.Web.Common.Responses.Authorization;
using Microsoft.AspNetCore.Http;
+using Polly.CircuitBreaker;
using System;
using System.Linq;
+using System.Net.Http;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
@@ -66,6 +70,38 @@ public class AuthorizationService : IAuthorizationService
string? userId = _httpContextAccessor.HttpContext?.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
if (string.IsNullOrEmpty(userId))
return new GetAuthorizationResponse(Guid.Empty, string.Empty, []);
- return await _apiHttpClient.GetAsync($"auth/get-authorization?userId={Uri.EscapeDataString(userId)}", cancellationToken);
+ try
+ {
+ return await _apiHttpClient.GetAsync($"auth/get-authorization?userId={Uri.EscapeDataString(userId)}", cancellationToken);
+ }
+ catch (Exception exception)
+ {
+ HttpContext? httpContext = _httpContextAccessor.HttpContext;
+ if (httpContext is null || httpContext.RequestAborted.IsCancellationRequested)
+ throw;
+ if (!IsApiOutage(exception))
+ throw;
+ bool isPageNavigation = (httpContext.Request.Headers.Accept.Count == 0 && httpContext.Request.Headers.Range.Count == 0)
+ || httpContext.Request.Headers.Accept.Any(accept => accept?.Contains("text/html", StringComparison.OrdinalIgnoreCase) == true)
+ || string.Equals(httpContext.Request.Headers["Sec-Fetch-Mode"].ToString(), "navigate", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(httpContext.Request.Headers["Sec-Fetch-Dest"].ToString(), "document", StringComparison.OrdinalIgnoreCase);
+ if (!isPageNavigation)
+ throw;
+ // The page is still rendered while the API is unreachable, with no role and no permissions, and the request is marked so
+ // that the page reports the failure to the user. API requests keep propagating the failure as a JSON error.
+ httpContext.Items[HttpContextItemKeys.SERVER_UNREACHABLE] = true;
+ return new GetAuthorizationResponse(Guid.Empty, string.Empty, []);
+ }
+ }
+
+ ///
+ /// Determines whether the exception means that the API could not answer, as opposed to an authorization answer from the API.
+ ///
+ /// The exception thrown by the API call.
+ /// for a connection, timeout, circuit breaker or server failure; otherwise .
+ private static bool IsApiOutage(Exception exception)
+ {
+ return exception is HttpRequestException or BrokenCircuitException or TaskCanceledException
+ || (exception is ApiException apiException && (int)apiException.HttpStatusCode >= 500);
}
}
diff --git a/src/Lumina.Presentation.Web/Common/Authorization/InitializationHandler.cs b/src/Lumina.Presentation.Web/Common/Authorization/InitializationHandler.cs
index 02788de9..b3059e93 100644
--- a/src/Lumina.Presentation.Web/Common/Authorization/InitializationHandler.cs
+++ b/src/Lumina.Presentation.Web/Common/Authorization/InitializationHandler.cs
@@ -1,9 +1,14 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Api;
+using Lumina.Presentation.Web.Common.Exceptions;
using Lumina.Presentation.Web.Common.Http;
using Lumina.Presentation.Web.Common.Responses.UsersManagement;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
+using Polly.CircuitBreaker;
+using System;
+using System.Linq;
+using System.Net.Http;
using System.Threading.Tasks;
#endregion
@@ -32,15 +37,51 @@ public class InitializationHandler : AuthorizationHandlerThe initialization requirement to be evaluated.
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext authorizationHandlerContext, InitializationRequirement initializationRequirement)
{
- InitializationResponse result = await _apiHttpClient.GetAsync("initialization/").ConfigureAwait(false);
- HttpContext? httpContext = authorizationHandlerContext.Resource as HttpContext;
- if (result.IsInitialized)
+ try
{
- // admin account was registered, remove this requirement from the session
- httpContext?.Session.Remove(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP);
+ InitializationResponse result = await _apiHttpClient.GetAsync("initialization/").ConfigureAwait(false);
+ HttpContext? httpContext = authorizationHandlerContext.Resource as HttpContext;
+ if (result.IsInitialized)
+ {
+ // admin account was registered, remove this requirement from the session
+ httpContext?.Session.Remove(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP);
+ authorizationHandlerContext.Succeed(initializationRequirement);
+ }
+ else // store in session that super admin setup is needed
+ httpContext?.Session.SetString(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP, "true");
+ }
+ catch (Exception exception)
+ {
+ HttpContext? httpContext = GetPageNavigationDuringApiOutage(authorizationHandlerContext, exception);
+ if (httpContext is null)
+ throw;
+ // The initialization state cannot be read while the API is unreachable, but the requested page is still rendered, and
+ // the failure is reported to the user there. The data calls of the page keep failing on their own.
+ httpContext.Items[HttpContextItemKeys.SERVER_UNREACHABLE] = true;
authorizationHandlerContext.Succeed(initializationRequirement);
}
- else // store in session that super admin setup is needed
- httpContext?.Session.SetString(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP, "true");
+ }
+
+ ///
+ /// Gets the current HTTP context when the provided exception is an API outage on a page navigation, and otherwise.
+ ///
+ /// The authorization context whose resource holds the HTTP context.
+ /// The exception thrown by the initialization check against the API.
+ /// The HTTP context of the page navigation, or when the exception must propagate.
+ private static HttpContext? GetPageNavigationDuringApiOutage(AuthorizationHandlerContext authorizationHandlerContext, Exception exception)
+ {
+ if (authorizationHandlerContext.Resource is not HttpContext httpContext)
+ return null;
+ if (httpContext.RequestAborted.IsCancellationRequested)
+ return null;
+ if (exception is not ApiException and not HttpRequestException and not BrokenCircuitException and not TaskCanceledException)
+ return null;
+ if (exception is ApiException apiException && (int)apiException.HttpStatusCode < 500)
+ return null;
+ bool isPageNavigation = (httpContext.Request.Headers.Accept.Count == 0 && httpContext.Request.Headers.Range.Count == 0)
+ || httpContext.Request.Headers.Accept.Any(accept => accept?.Contains("text/html", StringComparison.OrdinalIgnoreCase) == true)
+ || string.Equals(httpContext.Request.Headers["Sec-Fetch-Mode"].ToString(), "navigate", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(httpContext.Request.Headers["Sec-Fetch-Dest"].ToString(), "document", StringComparison.OrdinalIgnoreCase);
+ return isPageNavigation ? httpContext : null;
}
}
diff --git a/src/Lumina.Presentation.Web/Common/Authorization/PermissionAuthorizationHandler.cs b/src/Lumina.Presentation.Web/Common/Authorization/PermissionAuthorizationHandler.cs
index 70fef020..f6b488fa 100644
--- a/src/Lumina.Presentation.Web/Common/Authorization/PermissionAuthorizationHandler.cs
+++ b/src/Lumina.Presentation.Web/Common/Authorization/PermissionAuthorizationHandler.cs
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Authorization;
+using Lumina.Presentation.Web.Common.Http;
using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -13,14 +15,17 @@ namespace Lumina.Presentation.Web.Common.Authorization;
public class PermissionAuthorizationHandler : AuthorizationHandler
{
private readonly IAuthorizationService _authorizationService;
+ private readonly IHttpContextAccessor _httpContextAccessor;
///
/// Initializes a new instance of the class.
///
/// Injected service for authorization checks against the remote API.
- public PermissionAuthorizationHandler(IAuthorizationService authorizationService)
+ /// Injected accessor for the current HTTP context.
+ public PermissionAuthorizationHandler(IAuthorizationService authorizationService, IHttpContextAccessor httpContextAccessor)
{
_authorizationService = authorizationService;
+ _httpContextAccessor = httpContextAccessor;
}
///
@@ -44,5 +49,13 @@ public class PermissionAuthorizationHandler : AuthorizationHandler
{
private readonly IAuthorizationService _authorizationService;
+ private readonly IHttpContextAccessor _httpContextAccessor;
///
/// Initializes a new instance of the class.
///
/// Injected service for authorization checks against the remote API.
- public RoleAuthorizationHandler(IAuthorizationService authorizationService)
+ /// Injected accessor for the current HTTP context.
+ public RoleAuthorizationHandler(IAuthorizationService authorizationService, IHttpContextAccessor httpContextAccessor)
{
_authorizationService = authorizationService;
+ _httpContextAccessor = httpContextAccessor;
}
///
@@ -38,5 +42,13 @@ public class RoleAuthorizationHandler : AuthorizationHandler
return;
}
}
+ // The authorization service marks a page navigation when the API could not answer. The page itself is still rendered, with
+ // no role granted, and it reports the failure to the user; the API remains the enforcement point for every data call.
+ // Endpoint routing passes the Endpoint, not the HttpContext, as the authorization resource, so the current request is read
+ // from the accessor instead. Only an authenticated user is allowed through, because the outage is not a reason to expose a
+ // page to an anonymous visitor.
+ HttpContext? httpContext = _httpContextAccessor.HttpContext;
+ if (httpContext?.User.Identity?.IsAuthenticated == true && httpContext.Items[HttpContextItemKeys.SERVER_UNREACHABLE] is true)
+ authorizationHandlerContext.Succeed(roleRequirement);
}
}
diff --git a/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeLayoutModelDto.cs b/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeLayoutModelDto.cs
index b361e203..db32ff66 100644
--- a/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeLayoutModelDto.cs
+++ b/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeLayoutModelDto.cs
@@ -13,6 +13,7 @@ namespace Lumina.Presentation.Web.Common.DTO.Themes;
/// The rendered navigation menu of the page.
/// The rendered content section of the page.
/// The rendered audio player, when the current user is authenticated.
+/// The rendered server unreachable banner, placed by the layout.
/// The application global scripts, such as its client libraries and configuration.
/// The rendered script section of the page.
/// The inline style of the main content area, used to fill the viewport when the user is not authenticated.
@@ -24,6 +25,7 @@ public sealed record ThemeLayoutModelDto(
string Nav,
string Content,
string AudioPlayer,
+ string ServerUnreachableBanner,
string AppScripts,
string Scripts,
string MainStyle
diff --git a/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeServerUnreachableBannerDto.cs b/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeServerUnreachableBannerDto.cs
new file mode 100644
index 00000000..1b5e56ad
--- /dev/null
+++ b/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeServerUnreachableBannerDto.cs
@@ -0,0 +1,14 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Presentation.Web.Common.DTO.Themes;
+
+///
+/// Data transfer object for the model available to the themed server unreachable banner template.
+///
+/// The localized message that tells the user that the server is unreachable.
+[DebuggerDisplay("Message: {Message}")]
+public sealed record ThemeServerUnreachableBannerDto(
+ string Message
+);
diff --git a/src/Lumina.Presentation.Web/Common/Http/HttpContextItemKeys.cs b/src/Lumina.Presentation.Web/Common/Http/HttpContextItemKeys.cs
index 76feaf10..77ccf82f 100644
--- a/src/Lumina.Presentation.Web/Common/Http/HttpContextItemKeys.cs
+++ b/src/Lumina.Presentation.Web/Common/Http/HttpContextItemKeys.cs
@@ -9,6 +9,11 @@ public static class HttpContextItemKeys
public const string PENDING_SUPER_ADMIN_SETUP = "PendingSuperAdminSetup";
public const string LAST_DISPLAYED_VIEW = "LastViewUrl";
+ ///
+ /// Marks a rendered page whose authorization could not reach the API, so that the page reports the failure to the user.
+ ///
+ public const string SERVER_UNREACHABLE = "ServerUnreachable";
+
///
/// The Cache-Control value chosen by the endpoint, restored when the response starts.
///
diff --git a/src/Lumina.Presentation.Web/Common/Middlewares/ExceptionHandlingMiddleware.cs b/src/Lumina.Presentation.Web/Common/Middlewares/ExceptionHandlingMiddleware.cs
index 5dff1bc5..f7842e57 100644
--- a/src/Lumina.Presentation.Web/Common/Middlewares/ExceptionHandlingMiddleware.cs
+++ b/src/Lumina.Presentation.Web/Common/Middlewares/ExceptionHandlingMiddleware.cs
@@ -6,12 +6,16 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using System;
+using System.Globalization;
using System.Linq;
using System.Net;
+using System.Net.Http;
using System.Text;
+using System.Text.Encodings.Web;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
+using Polly.CircuitBreaker;
#endregion
namespace Lumina.Presentation.Web.Common.Middlewares;
@@ -67,12 +71,31 @@ public class ExceptionHandlingMiddleware
context.Abort();
return;
}
- // return a JSON result with the error details
- await WriteJsonResponseAsync(context, new
+ // A page navigation is answered with an HTML error page at the same address, so the browser never leaves the page the user
+ // asked for and never shows raw JSON. A JSON caller still receives the JSON error, and any other caller, like a media request,
+ // receives a bare status code, because neither an HTML page nor a JSON body is a representation such a caller can consume.
+ if (IsJsonRequest(context))
+ await WriteJsonResponseAsync(context, new
+ {
+ success = false,
+ serverUnreachable = IsApiOutage(ex),
+ errorMessage = _stringLocalizer["InternalServerError"].Value
+ });
+ else if (IsExplicitNavigationRequest(context))
+ await WriteHtmlErrorResponseAsync(context, (int)HttpStatusCode.InternalServerError, _stringLocalizer["InternalServerError"].Value).ConfigureAwait(false);
+ else if (IsNavigationRequest(context))
{
- success = false,
- errorMessage = ex.Message
- });
+ // A caller that states no preference is not necessarily a browser, so it keeps the historical JSON envelope instead of
+ // receiving an HTML page it cannot consume.
+ await WriteJsonResponseAsync(context, new
+ {
+ success = false,
+ serverUnreachable = IsApiOutage(ex),
+ errorMessage = _stringLocalizer["InternalServerError"].Value
+ });
+ }
+ else
+ await WriteStatusOnlyResponseAsync(context, (int)HttpStatusCode.InternalServerError).ConfigureAwait(false);
}
}
@@ -169,21 +192,74 @@ public class ExceptionHandlingMiddleware
///
private async Task HandleGenericApiErrorAsync(HttpContext context, ApiException apiException)
{
- // JSON callers and page navigations get the localized error message; any other caller, like an audio request, is answered with
- // a bare status code, because a JSON body is not a representation such a caller can consume.
- if (IsJsonRequest(context) || IsNavigationRequest(context))
+ // JSON callers get the localized error message, page navigations get an HTML error page at the same address, so the browser never
+ // leaves the page the user asked for and never shows raw JSON, and any other caller, like an audio request, is answered with a
+ // bare status code, because neither a JSON body nor an HTML page is a representation such a caller can consume.
+ if (IsJsonRequest(context))
{
string errorMessage = BuildErrorMessage(apiException);
await WriteJsonResponseAsync(context, new
{
success = false,
+ serverUnreachable = (int)apiException.HttpStatusCode >= 500,
errorMessage
});
}
+ else if (IsNavigationRequest(context))
+ {
+ bool isServerError = (int)apiException.HttpStatusCode >= 500;
+ string message = isServerError ? _stringLocalizer["InternalServerError"].Value : BuildErrorMessage(apiException);
+ await WriteHtmlErrorResponseAsync(context, (int)apiException.HttpStatusCode, message).ConfigureAwait(false);
+ }
else
await WriteStatusOnlyResponseAsync(context, (int)apiException.HttpStatusCode).ConfigureAwait(false);
}
+ ///
+ /// Determines whether the exception means that the server could not answer, as opposed to an answer the server produced.
+ ///
+ /// The exception thrown while handling the request.
+ /// for a connection, timeout, circuit breaker or server failure; otherwise .
+ private static bool IsApiOutage(Exception exception)
+ {
+ return exception is HttpRequestException or BrokenCircuitException or TaskCanceledException
+ || (exception is ApiException apiException && (int)apiException.HttpStatusCode >= 500);
+ }
+
+ ///
+ /// Writes a standalone HTML error page to the client, keeping the browser on the requested address.
+ ///
+ /// The for the current request.
+ /// The status code to answer with.
+ /// The localized message to show on the page.
+ private async Task WriteHtmlErrorResponseAsync(HttpContext context, int statusCode, string message)
+ {
+ context.Response.StatusCode = statusCode;
+ context.Response.ContentType = "text/html; charset=utf-8";
+ context.Response.Headers.CacheControl = "no-store";
+ string encodedMessage = HtmlEncoder.Default.Encode(message);
+ string encodedTitle = HtmlEncoder.Default.Encode(_stringLocalizer["Error"].Value);
+ string language = CultureInfo.CurrentUICulture.Name;
+ await context.Response.WriteAsync($$"""
+
+
+
+
+
+ {{encodedTitle}}
+
+
+
+
{{encodedTitle}}
+
{{encodedMessage}}
+
+
+ """).ConfigureAwait(false);
+ }
+
///
/// Handles unauthorized exceptions.
///
@@ -283,6 +359,22 @@ public class ExceptionHandlingMiddleware
|| string.Equals(context.Request.Headers["Sec-Fetch-Dest"].ToString(), "document", StringComparison.OrdinalIgnoreCase);
}
+ ///
+ /// Checks if the current request explicitly identifies itself as a browser navigation, rather than merely stating no preference.
+ ///
+ ///
+ /// A caller that sends no Accept header at all may be a script, a probe, or an API client, so it is not safe to answer it with
+ /// an HTML page. Only a request that asks for HTML or carries the browser navigation headers is treated as a page here.
+ ///
+ /// The for the current request.
+ /// when the request is explicitly a browser navigation, otherwise.
+ private static bool IsExplicitNavigationRequest(HttpContext context)
+ {
+ return context.Request.Headers.Accept.Any(accept => accept?.Contains("text/html", StringComparison.OrdinalIgnoreCase) == true)
+ || string.Equals(context.Request.Headers["Sec-Fetch-Mode"].ToString(), "navigate", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(context.Request.Headers["Sec-Fetch-Dest"].ToString(), "document", StringComparison.OrdinalIgnoreCase);
+ }
+
///
/// Writes a JSON response to the client.
///
diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ar-SA.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ar-SA.resx
index de5eee1d..38700fca 100644
--- a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ar-SA.resx
+++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ar-SA.resx
@@ -168,6 +168,9 @@
إعادة المحاولة
+
+ الخادم غير قابل للوصول
+
توسيع المشغل أو طيه
diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.de-DE.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.de-DE.resx
index 449c854e..b0450316 100644
--- a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.de-DE.resx
+++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.de-DE.resx
@@ -168,6 +168,9 @@
Wiederholen
+
+ Der Server ist nicht erreichbar
+
Player ein- oder ausklappen
diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.en-US.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.en-US.resx
index 061a5d8a..60b0a64c 100644
--- a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.en-US.resx
+++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.en-US.resx
@@ -168,6 +168,9 @@
Retry
+
+ Server is unreachable
+
Expand or collapse player
diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.es-ES.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.es-ES.resx
index c062afec..80316301 100644
--- a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.es-ES.resx
+++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.es-ES.resx
@@ -168,6 +168,9 @@
Reintentar
+
+ El servidor no está disponible
+
Expandir o contraer el reproductor
diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.fr-FR.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.fr-FR.resx
index 01d1eefa..cbd7f811 100644
--- a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.fr-FR.resx
+++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.fr-FR.resx
@@ -168,6 +168,9 @@
Réessayer
+
+ Le serveur est injoignable
+
Développer ou réduire le lecteur
diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.it-IT.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.it-IT.resx
index edf5d3e8..7625aa69 100644
--- a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.it-IT.resx
+++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.it-IT.resx
@@ -168,6 +168,9 @@
Riprova
+
+ Il server non è raggiungibile
+
Espandi o comprimi il lettore
diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ja-JP.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ja-JP.resx
index a483f88a..0cd44d9f 100644
--- a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ja-JP.resx
+++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ja-JP.resx
@@ -168,6 +168,9 @@
再試行
+
+ サーバーに接続できません
+
プレーヤーを展開または折りたたむ
diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.resx
index 061a5d8a..60b0a64c 100644
--- a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.resx
+++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.resx
@@ -168,6 +168,9 @@
Retry
+
+ Server is unreachable
+
Expand or collapse player
diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ro-RO.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ro-RO.resx
index dd43cd62..00c339c0 100644
--- a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ro-RO.resx
+++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.ro-RO.resx
@@ -168,6 +168,9 @@
Reîncercare
+
+ Serverul nu este disponibil
+
Extinde sau restrânge playerul
diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.uk-UA.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.uk-UA.resx
index 2aa5585a..02949014 100644
--- a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.uk-UA.resx
+++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.uk-UA.resx
@@ -168,6 +168,9 @@
Повторити
+
+ Сервер недоступний
+
Розгорнути або згорнути плеєр
diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.zh-CN.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.zh-CN.resx
index 9db7f001..dd803607 100644
--- a/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.zh-CN.resx
+++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Shared/_Layout.zh-CN.resx
@@ -168,6 +168,9 @@
重试
+
+ 服务器不可访问
+
展开或折叠播放器
diff --git a/src/Lumina.Presentation.Web/Core/Themes/ThemeLayoutRenderer.cs b/src/Lumina.Presentation.Web/Core/Themes/ThemeLayoutRenderer.cs
index 119d6a21..480cc1b0 100644
--- a/src/Lumina.Presentation.Web/Core/Themes/ThemeLayoutRenderer.cs
+++ b/src/Lumina.Presentation.Web/Core/Themes/ThemeLayoutRenderer.cs
@@ -2,7 +2,9 @@
using Lumina.Presentation.Web.Common.DTO.Themes;
using Lumina.Presentation.Web.Common.Primitives;
using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Localization;
using System;
+using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -17,6 +19,13 @@ public class ThemeLayoutRenderer
// the page keys mirror the paths of the corresponding Razor views under Core/Views, so that theme templates can override them at the page, section or default scope
private const string LAYOUT_PAGE_KEY = "shared/layout";
private const string NAV_PAGE_KEY = "shared/nav-menu";
+ private const string SERVER_UNREACHABLE_BANNER_PAGE_KEY = "shared/server-unreachable-banner";
+
+ // The banner template is static for a theme, so it is cached, including the negative result of a theme that does not
+ // provide one, so a missing template does not cost an API round trip and a 404 log on every page render.
+ private static readonly ConcurrentDictionary s_bannerTemplateCache = [];
+ private static readonly TimeSpan s_bannerTemplateCacheDuration = TimeSpan.FromMinutes(5);
+ private static readonly TimeSpan s_missingBannerTemplateCacheDuration = TimeSpan.FromMinutes(1);
private readonly ThemeService _themeService;
private readonly ThemeTemplateEngine _templateEngine;
@@ -24,6 +33,7 @@ public class ThemeLayoutRenderer
private readonly ThemeNavBuilder _navBuilder;
private readonly ThemeAudioPlayerRenderer _audioPlayerRenderer;
private readonly IHttpContextAccessor _httpContextAccessor;
+ private readonly IStringLocalizer _layoutLocalizer;
///
/// Initializes a new instance of the class.
@@ -34,7 +44,8 @@ public class ThemeLayoutRenderer
/// The builder used to produce the navigation menu model.
/// The renderer used to produce the themed audio player bar.
/// Injected accessor for the current HTTP context.
- public ThemeLayoutRenderer(ThemeService themeService, ThemeTemplateEngine templateEngine, RazorViewToStringRenderer viewRenderer, ThemeNavBuilder navBuilder, ThemeAudioPlayerRenderer audioPlayerRenderer, IHttpContextAccessor httpContextAccessor)
+ /// Injected factory used to create the localizer of the layout resources.
+ public ThemeLayoutRenderer(ThemeService themeService, ThemeTemplateEngine templateEngine, RazorViewToStringRenderer viewRenderer, ThemeNavBuilder navBuilder, ThemeAudioPlayerRenderer audioPlayerRenderer, IHttpContextAccessor httpContextAccessor, IStringLocalizerFactory stringLocalizerFactory)
{
_themeService = themeService;
_templateEngine = templateEngine;
@@ -42,6 +53,7 @@ public class ThemeLayoutRenderer
_navBuilder = navBuilder;
_audioPlayerRenderer = audioPlayerRenderer;
_httpContextAccessor = httpContextAccessor;
+ _layoutLocalizer = stringLocalizerFactory.Create("Lumina.Presentation.Web.Views.Shared._Layout", "Lumina.Presentation.Web");
}
///
@@ -62,6 +74,7 @@ public class ThemeLayoutRenderer
string appHead = await _viewRenderer.RenderPartialAsync("_ThemeLayoutHead", cancellationToken);
string nav = await RenderNavAsync(themeId, cancellationToken);
string audioPlayer = isAuthenticated ? await RenderAudioPlayerAsync(themeId, cancellationToken) : string.Empty;
+ string serverUnreachableBanner = await RenderServerUnreachableBannerAsync(themeId, cancellationToken);
string appScripts = await _viewRenderer.RenderPartialAsync("_ThemeLayoutScripts", cancellationToken);
ThemeLayoutModelDto layoutModel = new(
@@ -71,6 +84,7 @@ public class ThemeLayoutRenderer
nav,
page.Content,
audioPlayer,
+ serverUnreachableBanner,
appScripts,
page.Script,
isAuthenticated ? string.Empty : "bottom: 0px;");
@@ -139,4 +153,51 @@ public class ThemeLayoutRenderer
return await _viewRenderer.RenderPartialAsync("_AudioPlayer", cancellationToken);
}
+
+ ///
+ /// Renders the server unreachable banner of the active theme, falling back to the application Razor markup when the theme does not provide a template.
+ ///
+ /// The manifest id of the theme the layout was resolved with, so that the banner always matches the shell.
+ /// Cancellation token that can be used to stop the execution.
+ /// The rendered server unreachable banner HTML.
+ private async Task RenderServerUnreachableBannerAsync(string themeId, CancellationToken cancellationToken)
+ {
+ if (s_bannerTemplateCache.TryGetValue(themeId, out (string Template, DateTime ExpiresOnUtc) cached) && cached.ExpiresOnUtc > DateTime.UtcNow)
+ return await RenderBannerTemplateAsync(cached.Template, cancellationToken).ConfigureAwait(false);
+
+ string template = string.Empty;
+ try
+ {
+ ThemeRenderDocumentDto bannerDocument = await _themeService.GetRenderDocumentAsync(SERVER_UNREACHABLE_BANNER_PAGE_KEY, themeId, cancellationToken);
+ template = bannerDocument.Template;
+ }
+ catch (OperationCanceledException)
+ {
+ throw;
+ }
+ catch (Exception)
+ {
+ // The banner is best effort: when the theme template cannot be loaded or rendered, the application Razor fallback is rendered instead.
+ }
+ s_bannerTemplateCache[themeId] = (template, DateTime.UtcNow + (string.IsNullOrEmpty(template) ? s_missingBannerTemplateCacheDuration : s_bannerTemplateCacheDuration));
+ return await RenderBannerTemplateAsync(template, cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// Renders a banner template, or the application fallback when the theme does not provide one.
+ ///
+ /// The raw banner template source, or an empty string when the theme does not provide one.
+ /// Cancellation token that can be used to stop the execution.
+ /// The rendered server unreachable banner HTML.
+ private async Task RenderBannerTemplateAsync(string template, CancellationToken cancellationToken)
+ {
+ if (string.IsNullOrEmpty(template))
+ return await _viewRenderer.RenderPartialAsync("_ServerUnreachableBanner", cancellationToken);
+
+ ThemeServerUnreachableBannerDto bannerModel = new(_layoutLocalizer["ServerUnreachable"].Value);
+ Result renderResult = _templateEngine.RenderPage(template, bannerModel);
+ return renderResult.IsSuccess
+ ? renderResult.Value.Content
+ : await _viewRenderer.RenderPartialAsync("_ServerUnreachableBanner", cancellationToken);
+ }
}
diff --git a/src/Lumina.Presentation.Web/Core/Views/Admin/Scheduler.cshtml b/src/Lumina.Presentation.Web/Core/Views/Admin/Scheduler.cshtml
index 659b7633..de2ad4d5 100644
--- a/src/Lumina.Presentation.Web/Core/Views/Admin/Scheduler.cshtml
+++ b/src/Lumina.Presentation.Web/Core/Views/Admin/Scheduler.cshtml
@@ -737,10 +737,15 @@ It keeps the DOM contract the client script binds to, without any images or colo
schedulerHubConnection.on('ScheduledJobExecutionCompletedAsync', execution => {
loadJobsAsync();
});
+ schedulerHubConnection.onreconnecting(() => window.serverConnectionStatus.markUnreachable('scheduledJobsHub'));
+ schedulerHubConnection.onreconnected(() => window.serverConnectionStatus.markReachable('scheduledJobsHub'));
+ schedulerHubConnection.onclose(() => window.serverConnectionStatus.markUnreachable('scheduledJobsHub'));
try {
await schedulerHubConnection.start();
+ window.serverConnectionStatus.markReachable('scheduledJobsHub');
} catch (error) {
+ window.serverConnectionStatus.markUnreachable('scheduledJobsHub');
console.error('Failed to connect to the scheduled jobs hub:', error);
}
}
@@ -805,7 +810,7 @@ It keeps the DOM contract the client script binds to, without any images or colo
updateTimespanButton.removeEventListener('click', updateTimeSpanAsync);
addJobButton.removeEventListener('click', addJobAsync);
if (schedulerHubConnection)
- schedulerHubConnection.stop();
+ schedulerHubConnection.stop().finally(() => window.serverConnectionStatus.markReachable('scheduledJobsHub'));
});
}
diff --git a/src/Lumina.Presentation.Web/Core/Views/Library/Management/Index.cshtml b/src/Lumina.Presentation.Web/Core/Views/Library/Management/Index.cshtml
index 8221bcea..db4f7350 100644
--- a/src/Lumina.Presentation.Web/Core/Views/Library/Management/Index.cshtml
+++ b/src/Lumina.Presentation.Web/Core/Views/Library/Management/Index.cshtml
@@ -529,12 +529,15 @@
// Handle all SignalR stuff.
function setupSignalRHandlers() {
const onReconnecting = error => {
- console.log(error ? `SignalR reconnected with error: ${error}` : "SignalR reconnecting...");
+ window.serverConnectionStatus.markUnreachable('scanProgressHub');
+ console.log(error ? `SignalR reconnecting with error: ${error}` : "SignalR reconnecting...");
};
const onReconnected = connectionId => {
+ window.serverConnectionStatus.markReachable('scanProgressHub');
console.log('SignalR reconnected:', connectionId);
};
const onClose = error => {
+ window.serverConnectionStatus.markUnreachable('scanProgressHub');
console.log(error ? `SignalR connection closed with error: ${error}` : "SignalR connection closed");
};
// Progress update handler.
@@ -678,8 +681,9 @@
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
// Proper connection stop.
- if (signalRConnection.state === 'Connected')
- signalRConnection.stop().then(() => console.log('SignalR connection stopped'));
+ window.serverConnectionStatus.markReachable('scanProgressHub');
+ if (signalRConnection.state !== 'Disconnected')
+ signalRConnection.stop().finally(() => window.serverConnectionStatus.markReachable('scanProgressHub'));
btnScanAllLibraries.removeEventListener('click', handleScanAllLibrariesClick);
btnCancelLibrariesScan.removeEventListener('click', handleCancelLibrariesScanClick);
@@ -702,11 +706,18 @@
isInitialized = true;
try {
await loadLibrariesAsync();
- await signalRConnection.start();
+ try {
+ await signalRConnection.start();
+ window.serverConnectionStatus.markReachable('scanProgressHub');
+ } catch (err) {
+ window.serverConnectionStatus.markUnreachable('scanProgressHub');
+ console.error('SignalR connection failed:', err);
+ return;
+ }
setupSignalRHandlers();
await getRunningLibraryScansAsync();
} catch (err) {
- console.error('SignalR connection failed:', err);
+ console.error('Failed to initialize the libraries page:', err);
}
}
diff --git a/src/Lumina.Presentation.Web/Core/Views/Shared/Error.cshtml b/src/Lumina.Presentation.Web/Core/Views/Shared/Error.cshtml
index 70efbfcf..1e643440 100644
--- a/src/Lumina.Presentation.Web/Core/Views/Shared/Error.cshtml
+++ b/src/Lumina.Presentation.Web/Core/Views/Shared/Error.cshtml
@@ -1,26 +1,38 @@
@using Lumina.Presentation.Web.Common.DTO.Common
+@using Lumina.Presentation.Web.Common.Services
+@using Microsoft.Extensions.Localization
+
@model ErrorViewDto
+@inject IStringLocalizerFactory _stringLocalizerFactory
+
@{
ViewData["Title"] = "Error";
+ var scriptId = ScriptIdentifierHelper.GenerateScriptId();
+ var localizer = _stringLocalizerFactory.Create("Lumina.Presentation.Web.Views.Shared._Layout", "Lumina.Presentation.Web");
}
-
Error.
-
An error occurred while processing your request.
+
+
+
+
+
+
@localizer["Error"]
+
@localizer["NavigationFailed"]
+ @if (Model.ShouldShowRequestId)
+ {
+
+ Request ID:@Model.RequestId
+
+ }
+
+
+
-@if (Model.ShouldShowRequestId)
-{
-
- Request ID:@Model.RequestId
-
+@section Scripts {
+
}
-
-
Development Mode
-
- Swapping to Development environment will display more detailed information about the error that occurred.
-
-
- The Development environment shouldn't be enabled for deployed applications.
- It can result in displaying sensitive information from exceptions to end users.
- For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
- and restarting the app.
-
diff --git a/src/Lumina.Presentation.Web/Core/Views/Shared/_Layout.cshtml b/src/Lumina.Presentation.Web/Core/Views/Shared/_Layout.cshtml
index f04be11b..67e11e60 100644
--- a/src/Lumina.Presentation.Web/Core/Views/Shared/_Layout.cshtml
+++ b/src/Lumina.Presentation.Web/Core/Views/Shared/_Layout.cshtml
@@ -1,4 +1,5 @@
@using Lumina.Presentation.Web.Common.DTO.Themes
+@using Lumina.Presentation.Web.Common.Http
@using Lumina.Presentation.Web.Common.Primitives
@using Lumina.Presentation.Web.Core.Themes
@using Microsoft.AspNetCore.Html
@@ -17,6 +18,11 @@
bodyHtml = bodyWriter.ToString();
}
+ // The page renders even when the API was unreachable during its authorization check. The marker is carried inside the main content,
+ // so the global script reports the failed navigation both on a full page load and after an AJAX navigation swapped the content.
+ if (ViewContext.HttpContext.Items[HttpContextItemKeys.SERVER_UNREACHABLE] is true)
+ bodyHtml = "" + bodyHtml;
+
string scriptsHtml;
using (StringWriter scriptsWriter = new())
{
@@ -63,6 +69,7 @@ else
@await Html.PartialAsync("_AudioPlayer")
}