2009-11-23 4 views

답변

1

감사합니다.

해결책을 찾았습니다.

내가 HandleErrorWithELMAHAttribute (How to get ELMAH to work with ASP.NET MVC [HandleError] attribute?) 를 사용하고 있는데 OnException 방법으로 내보기 설정 한 : 나는 함께하고 redirectMode없이 작동하고있는 defaultRedirect은 customErrors에 태그에서 속성 것으로 나타났습니다

public override void OnException(ExceptionContext context) 
{ 
    View = "AdminError"; // this is my view 
    base.OnException(context); 

    var e = context.Exception; 
    if (!context.ExceptionHandled // if unhandled, will be logged anyhow 
     || RaiseErrorSignal(e)  // prefer signaling, if possible 
     || IsFiltered(context))  // filtered? 
    return; 

    LogException(e); 
} 

합니다.

1

Asp.net mvc는 이러한 종류의 요구 사항을 처리하기 위해 [HandleError] 특성을 제공하므로 특정 오류 유형에 따라 리디렉션 할 다른 오류 페이지 (보기)를 지정할 수 있습니다. 그것은 매우 유연하고 그렇게하는 것이 좋습니다. 예를

를 들어

[HandleError(ExceptionType = typeof(NullReferenceException), 
    View = "NullError")] 
[HandleError(ExceptionType = typeof(SecurityException), 
    View = "SecurityError")] 
public class HomeController : Controller 
{ 
    public ActionResult Index() 
    { 
     throw new NullReferenceException(); 
    } 

    public ActionResult About() 
    { 
     return View(); 
    } 
} 

체크 아웃 this similar question 자세한 정보를 찾을 수 있습니다.

관련 문제