Search code examples
asp.netasp.net-mvcwebformsasp.net-mvc-controller

Getting scrambled code instead of error page on .NET 4.5


Whenever a error is thrown during the loading cycle (page load, map request ...) of any of my .Net 4.5 components (controller, webforms ...) I got the following scrambled code:

Scrambled code

Any exception leads to the above, DB connection time out, route parameter type cast error you name it... Is it caused by the loading event not being followed through due to the exception? How to get it right?


Solution

  • Turned out this was because the exception was thrown in the controller w/o getting caught and handled which prevented the controller from thoroughly processing the request...

    Once I set up to catch and handle the exception it's all roses again.

    For anyone who is interested in how to properly handle controller exceptions the below makes a good point of reference: Exception handling in Controller (ASP.NET MVC)