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

@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -51,7 +46,8 @@ namespace Website
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseExceptionHandler("/Error/ServerError");
app.UseStatusCodePagesWithReExecute("/Error/PageNotFound");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}