我想在重写方法OnException中处理异常,如下所示: if i filterContext.ExceptionHandled = true; 返回视图将显示空白视图。 我不希望它重定向到500页。 那我该怎么办?我怎样才能捕捉到MVC3异常并且不返回空白视图?
protected override void OnException(ExceptionContext filterContext)
{
base.OnException(filterContext);
var exception = new HttpException(null, filterContext.Exception);
if (exception.GetHttpCode() == (int)HttpStatusCode.InternalServerError)
{
if (WebConstants.systemHandleExceptionList.Contains(filterContext.Exception.GetType()))
{
//process the error
SaveErrorMessage(filterContext.Exception.GetType().Name);
filterContext.ExceptionHandled = true;
}
else
{
//record the unhandle message to log
errorlog.Error("", filterContext.Exception);
}
}
}
你想做什么? –