Created dedicated controller and pages to status pages.
This commit is contained in:
parent
bbb052db9c
commit
f9758df24f
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
@model int
|
||||
|
||||
@{
|
||||
ViewBag.Title = $"Status - {Model}";
|
||||
Layout = "_Layout";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2>Sorry - Status @Model</h2>
|
||||
@switch (Model)
|
||||
{
|
||||
case 404:
|
||||
<p>Sorry it looks like the resource you clicked on, doesn't exist...</p>
|
||||
<p>Which is strange, unless you created the link yourself</p>
|
||||
<p>If you clicked a link, my apologies</p>
|
||||
<p>If you copied the link, make sure it is correct.</p>
|
||||
break;
|
||||
default:
|
||||
<p>Sorry I hadn't planned for this error occuring...</p>
|
||||
<p>Which I agree, is rather awkward.</p>
|
||||
break;
|
||||
}
|
||||
<p>here's a complementary link back to files</p>
|
||||
<a asp-controller="Files" asp-action="Index" class="btn btn-primary">Go back to Files</a>
|
||||
</div>
|
||||
Loading…
Reference in New Issue