Refactor error handling. Add 404 page

This commit is contained in:
Robert Marshall 2019-04-27 22:03:50 +01:00
parent 2475d1963c
commit 647696aa92
5 changed files with 38 additions and 17 deletions

View file

@ -0,0 +1,27 @@
using System;
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Website.ViewModels;
namespace Website.Controllers
{
public class ErrorController : Controller
{
public IActionResult BlowUp() {
throw new Exception();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult ServerError()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult PageNotFound()
{
return View();
}
}
}