Stefanvds
Stefanvds

Reputation: 5916

Elmah (mvc4) ignores the customErrors (but it logs)

I've just migrated a MVC3 project to a 4.

I also installed the newest update of ELMAH.

I do have an issue with unhandled exceptions.

In my web.config I have this:

<customErrors mode="On" defaultRedirect="/Error/Error" redirectMode="ResponseRedirect">
  <error statusCode="404" redirect="/Error/NotFound" />
</customErrors>

When I get an unhandled exception, Elmah logs it, no problem there, but it doesnt send me to the Error/Error view. It also doesn't do the 'ResponseRedirect'

What it does instead is keep the URL as it was, and it shows me the Error.aspx view from the Shared folder.

How do I change the settings somewhere, that the customErrors won't be ignored?

Upvotes: 0

Views: 539

Answers (1)

VJAI
VJAI

Reputation: 32758

If you are seeing the Error.aspx page then definitely HandleError filter is playing behind it. Go to Global.asax.cs and check HandleErrorAttribute is not added in the RegisterGlobalFilters method.

Also make sure you haven't overridden the OnException method of the controller and doing something manually yourself.

Upvotes: 2

Related Questions