1

我在 MVC3 应用程序中有一个自定义错误处理程序类属性。它ExceptionContext作为参数。我想在编写错误日志后重定向到 error.html 页面。我已经尝试过,但它不起作用。请问有什么建议吗?

context.Result = new RedirectResult("~/Error.html");

自定义错误处理程序

private static void LogUnhandledException(ExceptionContext context)
{
    var e = context.Exception;
    ErrorLog.Error(1, e.Message, e, "test");

    // Redirect to Error Page
    //context.Result = new RedirectResult("~/Error.htm");
    context.Result = new FilePathResult("~/Error.htm", "text/html");
}

谢谢

4

1 回答 1

3

尝试这个

    context.Result = new FilePathResult("~/Error.html", "text/html");

而且我认为您应该在Error Actionnot in 中执行此操作HandleErrorAttribute

public ActionResult Error(){
   var result = new FilePathResult("~/Error.html", "text/html");
   return result;
}
于 2012-06-20T10:38:48.083 回答