Search code examples
asp.net-mvcelmah

Why Elmah set 0 for code in internal errors?


Recently I created an ASP.NET MVC 5 application and installed Elmah.MVC.2.1.2 from the nugget package management on it.

Every things looks OK and Elmah logs all errors but when it logs internal errors it set 0 for code. I think it should set 5xx error code for theirs, am I right or not? If I'm right, where should I configure it?

enter image description here

Thanks in advanced (:


Solution

  • ELMAH only shows the status code, if the thrown exception is of type HttpException. You can either catch the exception inside the controller and re-throw it as a HttpException or write a filter converting uncaught exceptions to HttpException.