Ed DeGagne
Ed DeGagne

Reputation: 3269

MVC 4 - How do I turn off the default Error.vbhtml page?

Anyone know how to turn off the default error page or where it's referenced??

Upvotes: 4

Views: 5198

Answers (2)

Ed DeGagne
Ed DeGagne

Reputation: 3269

Alright, I figured it out.

Turns out that in my custom ElmahHandleErrorAttribute class, the OnException() method is indeed over ridden (as it should be). But the 1st line of code is "MyBase.OnException(context)", which will fire off what the HandleError attribute also performs.

Once I commented out that one line, my issue went away.

What's The Issue?

I have Elmah.Mvc implemented in this Mvc4 project, it's working beautifully. I also have a custom errors section in the Web.config as follows:

<customErrors mode="On" defaultRedirect="~/Error/General">
  <error statusCode="404" redirect="~/Error/Http404" />
</customErrors>

I have an ErrorController with two action methods, one for "General" and the other for "Http404".

What was happening was if I raised an unhandled error, I would indeed get my raised exception logged in Elmah, an email delivered with the exception, and then the custom "General" view displayed (Http404 page if it was a 404 error).

BUT, what I was also getting was an additional logged exception AND email because the default "Error.vbhtml" file was not found (I removed that view).

Honest mistake...hope this helps someone out moving along. :)

Upvotes: 2

Clafou
Clafou

Reputation: 15400

You can control this using the customErrors element in the web.config file.

Upvotes: -1

Related Questions