2

「ExceptionType」パラメーターの有無にかかわらず、これを試しました。Views/Shared フォルダーと Views/thisController フォルダーの両方に Error.aspx ページがあります。しかし、これを実行するたびに、「'/' アプリケーションでサーバー エラーが発生しました。」Views/Shared の素敵なページではなく、エラー ページ。

ここで何がうまくいかないのでしょうか?

[HandleError(View="Error",ExceptionType=typeof(FormatException))]

    public ActionResult Create()
    {
        throw new Exception();
        //int breakMe = int.Parse("not a number");
        return View();
    }
4

2 に答える 2

3

私は実際にこれを私のweb.configに持っています

<customErrors mode="On"></customErrors>

他の何かが動いているに違いない。

于 2008-12-03T01:32:50.503 に答える
1

現在のプロジェクトまたは新しいプロジェクトでは機能しません。それはおそらく「特徴」です。

編集: HandleErrorAttribute.csからのこのスニペットに従って動作するために、customErrorsが有効になっている(mode = "On")ようです:

// If custom errors are disabled, we need to let the normal ASP.NET exception handler
// execute so that the user can see useful debugging information.
if (filterContext.ExceptionHandled || !filterContext.HttpContext.IsCustomErrorEnabled) {
  return;
}
于 2008-12-03T01:21:42.477 に答える