Web.config
<customErrors mode="On" defaultRedirect="~/Error/HttpError"> // is not working
<error redirect="~/Error/NotFound" statusCode="404" />
<error redirect="~/Error/HttpError" statusCode="500" /> // also it is not working
</customErrors>
エラーコントローラー
public class ErrorController : Controller
{
//
// GET: /Error/
public ActionResult HttpError()
{
return Content("HttpError was called!");
//return View("Error");
}
public ActionResult NotFound(string aspxerrorpath)
{
return View();
}
public ActionResult Index()
{
return RedirectToAction("Index", "Home");
}
}
404エラーの場合は、NotFoundアクションも呼び出しますが、その他のエラーの場合は、HttpErrorメソッドにヒットすることはありません。
public ActionResult ETest()
{
throw new Exception("yahoo");
}
上記のテストコードを実行すると、Error.cshtmlページに直接移動します。
私が間違っていることは何ですか?