1
ASP.NET MVC : 컨트롤러가 catch 블록에 들어갈 때를 알 수있는 필터가 있습니까? OnException은 실제로 처리되지 않은 4 개의 ex라는 사실을 기반으로 작동하지 않습니다.모든 예외에 대한 ASP.NET MVC 필터 (이미 처리 된 포함)
ASP.NET MVC : 컨트롤러가 catch 블록에 들어갈 때를 알 수있는 필터가 있습니까? OnException은 실제로 처리되지 않은 4 개의 ex라는 사실을 기반으로 작동하지 않습니다.모든 예외에 대한 ASP.NET MVC 필터 (이미 처리 된 포함)
당신은 당신의 자신의 속성이
public class LogExceptionAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
}
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
//here you can inspect filterContext for exceptions
base.OnActionExecuted(filterContext);
}
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
base.OnResultExecuting(filterContext);
}
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
base.OnResultExecuted(filterContext);
}
}
ActionFilterAttribute
에서 파생 쓰기 그리고 액션/컨트롤러의 속성을 넣어 또는 Global.asax에, 글로벌 필터로ApplicationStart()
에 등록 할 수 있습니다. 예 : 예외를 로그인하거나 다른 일을 할 수있게된다
[LogException]
public ActionResult Index()
{
throw new Exception();
return View();
}
.
그냥 처리되지 않은 예외 (이 일을 순서대로 예외를 rethrow합니다) 작동합니다. – raulgomis
catch 블록 내에서 예외를 다시 발생시키지 않으면 예외가 아닙니다. –