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 Actionそして、これは ではなく で行う必要があると思いますHandleErrorAttribute:

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