전역 예외 필터를 사용하여 모든 예외를 처리하고 기록합니다. 그것은 OnException
메소드를 오버라이드 (override) -ExceptionContext.ExceptionHandled가 true로 변경됩니다. 예외 처리는 어디에서 처리됩니까?
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new ElmahHandleErrorAttribute());
filters.Add(new HandleErrorAttribute());
}
이 글로벌 액션 필터 ElmahHandleErrorAttribute
가 정의하는 방법입니다. OnException
방법이 실행될 때 context.ExceptionHandled
의 값이 true 이유
public class ElmahHandleErrorAttribute : System.Web.Mvc.HandleErrorAttribute
{
public override void OnException(ExceptionContext context)
{
//Is the exception handled already? context.ExceptionHandled seems to be true here
if (!context.IsChildAction && (context.HttpContext.IsCustomErrorEnabled))
{
//Do other stuff stuff
//Log to Elmah
}
}
...
}
는 이해가 안 돼요. 이 예외는 어떻게 처리됩니까?
-EDIT-
은 내가Web.Config
에
customErrors
섹션이 있습니다.
ErrorController
클래스가 있고
General
및
Http404
이라는 작업이 있습니다.
ElmahHandleErrorAttribute
시작의
OnException
방법은 실행시,하지만
ExceptionContext.ExceptionHandled
의 값이 true로 설정되어 내가 (중단 점 적중되지 않습니다), 컨트롤러 액션
General
가 실행되지 않습니다 이해하지
<customErrors mode ="On" defaultRedirect="Error/General">
<error statusCode="404" redirect="Error/Http404"/>
</customErrors>
.
코드에서'context.ExceptionHandled'를 볼 수 없습니다. 어디에 있습니까? – gdoron
@gdoron context.ExceptionHandled에 대한 검사를 제거했습니다.'if (! context.IsChildAction &&! context.ExceptionHandled && (context.HttpContext.IsCustomErrorEnabled))' – escist
컨트롤러의'OnException' 메소드를 오버라이드 했습니까? – gdoron