I have default template of MVC4 project and following subscription for UnhandledException event in my Global.asax:
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlAppDomain)]
protected void Application_Start()
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Debugger.Break();
// Some logging code here
}
In my HomeController Index action I simply write:
throw new Exception("Test exception"):
Console application with such subscription works fine. But in MVC project handler call never occurs. What is wrong with MVC?