2

I've tried this both with and without the 'ExceptionType' parameter. I have an Error.aspx page in both the Views/Shared folder and the Views/thisController folder. But everytime I run this I get a "Server Error in '/' Application." error page, rather than the nice one in Views/Shared.

Any idea what could be going wrong here?

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

    public ActionResult Create()
    {
        throw new Exception();
        //int breakMe = int.Parse("not a number");
        return View();
    }
Jeff Keslinke
  • 4,278
  • 5
  • 30
  • 49

2 Answers2

3

I do indeed have this in my web.config

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

Must be something else at play.

Schotime
  • 15,707
  • 10
  • 46
  • 75
  • When I change mode from RemoteOnly to On it started working for me. – Todd Smith Dec 03 '08 at 01:50
  • I figured it out. Its because i'm using a custom view engine so that all my pages are in an app directory like Rob Conery does for the MVC storefront. The HandleError does not work in this situation..Could be an MVC bug. – Schotime Dec 03 '08 at 03:26
  • I have emailed Phil Haack and this is confirmed as a bug. – Schotime Dec 06 '08 at 05:28
1

It doesn't work for me on my current project or a new one. It's probably a "feature".

EDIT: it looks like you have customErrors enabled (mode="On") for it to work according to this snippet from HandleErrorAttribute.cs:

// 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;
}
Todd Smith
  • 17,084
  • 11
  • 59
  • 78