From 03313562d21d5db9bf6a14ebbeab80e06c883d3a Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 24 Jan 2024 02:31:56 +0100 Subject: MRU->RMU, fixes, cleanup --- MatrixUtils.Web.Server/Pages/Error.cshtml | 41 ++++++++++++++++++++++++++++ MatrixUtils.Web.Server/Pages/Error.cshtml.cs | 19 +++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 MatrixUtils.Web.Server/Pages/Error.cshtml create mode 100644 MatrixUtils.Web.Server/Pages/Error.cshtml.cs (limited to 'MatrixUtils.Web.Server/Pages') diff --git a/MatrixUtils.Web.Server/Pages/Error.cshtml b/MatrixUtils.Web.Server/Pages/Error.cshtml new file mode 100644 index 0000000..a29e836 --- /dev/null +++ b/MatrixUtils.Web.Server/Pages/Error.cshtml @@ -0,0 +1,41 @@ +@page +@model MatrixUtils.Web.Server.Pages.ErrorModel + + + + + + + + Error + + + + + +
+
+

Error.

+

An error occurred while processing your request.

+ + @if (Model.ShowRequestId) { +

+ Request ID: @Model.RequestId +

+ } + +

Development Mode

+

+ Swapping to the Development environment displays 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. +

+
+
+ + + \ No newline at end of file diff --git a/MatrixUtils.Web.Server/Pages/Error.cshtml.cs b/MatrixUtils.Web.Server/Pages/Error.cshtml.cs new file mode 100644 index 0000000..3afc061 --- /dev/null +++ b/MatrixUtils.Web.Server/Pages/Error.cshtml.cs @@ -0,0 +1,19 @@ +using System.Diagnostics; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace MatrixUtils.Web.Server.Pages; + +[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] +[IgnoreAntiforgeryToken] +public class ErrorModel : PageModel { + private readonly ILogger _logger; + + public ErrorModel(ILogger logger) => _logger = logger; + + public string? RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + public void OnGet() => RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; +} -- cgit 1.5.1