0

I am trying the MVC3 exception handling, and came with following test code:

public class HomeController : Controller {
    public ActionResult Index() {
        throw new ArgumentException();
        return View();
    }
}

My controller forces to throw exception, and in my web.config

<customErrors mode="On" defaultRedirect="~/ErrorHandler/Index">
  <error statusCode="404" redirect="~/ErrorHandler/NotFound"></error>
</customErrors>

I have created another controller to server ErrorHandler/Index and ErrorHandler/NotFound request already.

With my testing, I can see the 404 code could be captured but 500 code has been ignore totally.

Anything wrong with my code?

Thanks Hardy

1 Answer 1

3

Remove the following line:

filters.Add(new HandleErrorAttribute());

from the RegisterGlobalFilters method in your Global.asax.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.