소스 검색

Made error pages actually return the correct status codes.

tags/2.0.3
Teknikode 5 년 전
부모
커밋
af77b43890
3개의 변경된 파일29개의 추가작업 그리고 2개의 파일을 삭제
  1. 0
    1
      Teknik/App_Start/RouteConfig.cs
  2. 28
    1
      Teknik/Areas/Error/Controllers/ErrorController.cs
  3. 1
    0
      Teknik/Web.config

+ 0
- 1
Teknik/App_Start/RouteConfig.cs 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

@@ -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…
취소
저장