Browse Source

Made error pages actually return the correct status codes.

tags/2.0.3
Teknikode 4 years ago
parent
commit
af77b43890

+ 0
- 1
Teknik/App_Start/RouteConfig.cs 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" });
}
}
}

+ 28
- 1
Teknik/Areas/Error/Controllers/ErrorController.cs 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;


+ 1
- 0
Teknik/Web.config 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">

Loading…
Cancel
Save