From 4ea6a19cf69847e2d38b742a7571bda071a3ba4d Mon Sep 17 00:00:00 2001
From: Laura Hausmann
Date: Sat, 26 Nov 2022 13:47:14 +0100
Subject: [PATCH] Rework page errors
---
Backend/Startup.cs | 4 +++-
Pages/Error.cshtml | 11 -----------
Pages/ErrorPages/404.cshtml | 7 +++++++
3 files changed, 10 insertions(+), 12 deletions(-)
create mode 100644 Pages/ErrorPages/404.cshtml
diff --git a/Backend/Startup.cs b/Backend/Startup.cs
index fc06b00..663e4a8 100644
--- a/Backend/Startup.cs
+++ b/Backend/Startup.cs
@@ -32,6 +32,8 @@ if (!app.Environment.IsDevelopment()) {
var provider = new FileExtensionContentTypeProvider { Mappings = { [".gpg"] = "application/pgp-signature" } };
app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider });
+app.UseStatusCodePagesWithReExecute("/ErrorPages/{0}");
+
app.UseSession();
app.UseRouting();
app.UseAuthorization();
@@ -39,4 +41,4 @@ app.UseAuthorization();
app.MapRazorPages();
app.MapControllers();
-app.Run();
\ No newline at end of file
+app.Run();
diff --git a/Pages/Error.cshtml b/Pages/Error.cshtml
index 8f24ea4..5e0abe5 100644
--- a/Pages/Error.cshtml
+++ b/Pages/Error.cshtml
@@ -12,14 +12,3 @@
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/Pages/ErrorPages/404.cshtml b/Pages/ErrorPages/404.cshtml
new file mode 100644
index 0000000..1e2079f
--- /dev/null
+++ b/Pages/ErrorPages/404.cshtml
@@ -0,0 +1,7 @@
+@page
+@{
+ ViewData["Title"] = "error_404";
+}
+
+Not found.
+The page you requested does not exist on this server.