Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ELMAH not displaying Original ASP.NET error page in MVC3

http://www.matheda.com/Blog/Details/3/Exception-Logging-with-ELMAH

Using the above url as a reference, I can see ELMAH should display the Original ASP.NET error page when the error originates from the View.

I have created the following view to generate an error, but the only exception views are Raw/Source data in XML or in JSON.

@{
    ViewBag.Title = "ViewError";
}

<h2>View Error</h2>

@{
  throw new NullReferenceException();
}

Is it possible to view the Original ASP.NET error page in MVC3?

like image 615
joelnet Avatar asked Feb 26 '23 04:02

joelnet


2 Answers

MVC3 now has a different process for handling errors that bypasses the HttpApplication's error handling, and I am not sure that ELMAH can recreate the yellow screen of death at that point.

CodeSmith Insight has very similar functionality to ELMAH, and we had to create a new MVC3 specific HttpModule to continue getting all of our exception details. Here is a blog post about our implementation, hope that helps.

like image 96
tdupont Avatar answered Mar 17 '23 09:03

tdupont


If I Recall Correctly, ELMAH will call Server.GetLastError(), which means if any error happened after the error you're expecting, you might get an ELMAH report that is different than your expectations.

I know this happened to me when my 404 page wasn't really there... I got spammed by page-not-found errors when there was a different error altogether.

like image 42
JMP Avatar answered Mar 17 '23 10:03

JMP