1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Made error pages actually return the correct status codes.

This commit is contained in:
Uncled1023 2016-05-27 15:55:11 -07:00
parent 654f684c78
commit af77b43890
3 changed files with 29 additions and 2 deletions

View File

@ -15,7 +15,6 @@ namespace Teknik
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = ".*/favicon\\.ico" });
}
}
}

View File

@ -19,7 +19,10 @@ namespace Teknik.Areas.Error.Controllers
ViewBag.Description = "Just a boring 'ol exception. Nothing to see here, move along.";
if (Response != null)
Response.StatusCode = 200;
{
Response.StatusCode = 500;
Response.TrySkipIisCustomErrors = true;
}
ErrorViewModel model = new ErrorViewModel();
model.Exception = exception;
@ -34,6 +37,12 @@ namespace Teknik.Areas.Error.Controllers
ViewBag.Title = "Http Exception - " + Config.Title;
ViewBag.Description = "There has been a Http exception. Run!";
if (Response != null)
{
Response.StatusCode = 500;
Response.TrySkipIisCustomErrors = true;
}
ErrorViewModel model = new ErrorViewModel();
model.Description = exception.Message;
model.Exception = exception;
@ -48,6 +57,12 @@ namespace Teknik.Areas.Error.Controllers
ViewBag.Title = "403 - " + Config.Title;
ViewBag.Description = "Access Denied";
if (Response != null)
{
Response.StatusCode = 403;
Response.TrySkipIisCustomErrors = true;
}
ErrorViewModel model = new ErrorViewModel();
model.Exception = exception;
@ -61,6 +76,12 @@ namespace Teknik.Areas.Error.Controllers
ViewBag.Title = "404 - " + Config.Title;
ViewBag.Description = "Uh Oh, can't find it!";
if (Response != null)
{
Response.StatusCode = 404;
Response.TrySkipIisCustomErrors = true;
}
ErrorViewModel model = new ErrorViewModel();
model.Exception = exception;
@ -74,6 +95,12 @@ namespace Teknik.Areas.Error.Controllers
ViewBag.Title = "500 - " + Config.Title;
ViewBag.Description = "Something Borked";
if (Response != null)
{
Response.StatusCode = 500;
Response.TrySkipIisCustomErrors = true;
}
ErrorViewModel model = new ErrorViewModel();
model.Exception = exception;

View File

@ -52,6 +52,7 @@
<add name="strict-transport-security" value="max-age=31536000; includeSubdomains" />
</customHeaders>
</httpProtocol>
<httpErrors errorMode="Detailed" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">