diff --git a/FileStorageService.www/Controllers/ErrorController.cs b/FileStorageService.www/Controllers/ErrorController.cs new file mode 100644 index 0000000..cc1af1e --- /dev/null +++ b/FileStorageService.www/Controllers/ErrorController.cs @@ -0,0 +1,13 @@ +using System.Net; +using Microsoft.AspNetCore.Mvc; + +namespace FileStorageService.www.Controllers; + +public class ErrorController : Controller +{ + // GET + public IActionResult Status(int id) + { + return View(id); + } +} \ No newline at end of file diff --git a/FileStorageService.www/Controllers/HomeController.cs b/FileStorageService.www/Controllers/HomeController.cs index 9f2a19d..a6bf0fa 100644 --- a/FileStorageService.www/Controllers/HomeController.cs +++ b/FileStorageService.www/Controllers/HomeController.cs @@ -27,12 +27,4 @@ public class HomeController : Controller { return View(); } - - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, - NoStore = true)] - public IActionResult Error() - { - return View(new ErrorViewModel - { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); - } } \ No newline at end of file diff --git a/FileStorageService.www/Program.cs b/FileStorageService.www/Program.cs index 9748fa1..da9f7a5 100644 --- a/FileStorageService.www/Program.cs +++ b/FileStorageService.www/Program.cs @@ -30,12 +30,14 @@ if (app.Environment.IsDevelopment()) } else { - app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); + +app.UseStatusCodePagesWithRedirects("/Error/Status/{0}"); + app.UseRouting(); app.MapStaticAssets(); diff --git a/FileStorageService.www/Views/Error/Status.cshtml b/FileStorageService.www/Views/Error/Status.cshtml new file mode 100644 index 0000000..9a78cac --- /dev/null +++ b/FileStorageService.www/Views/Error/Status.cshtml @@ -0,0 +1,25 @@ +@model int + +@{ + ViewBag.Title = $"Status - {Model}"; + Layout = "_Layout"; +} + +
Sorry it looks like the resource you clicked on, doesn't exist...
+Which is strange, unless you created the link yourself
+If you clicked a link, my apologies
+If you copied the link, make sure it is correct.
+ break; + default: +Sorry I hadn't planned for this error occuring...
+Which I agree, is rather awkward.
+ break; + } +here's a complementary link back to files
+ Go back to Files +