How to handle invisible exceptions in asp.net mvc

I specifically ask how to handle invisible exceptions, rather than unhandled exceptions. This question also differs from this question , which asks how to improve asynchronous start and forget methods, and not how to handle invisible exceptions, although they are related.

Unusual exceptions are a type caused by the following example, taken from here :

Task op1 = FooAsync(); Task op2 = BarAsync(); await op1; await op2; 

As a rule, I try to avoid this situation, but if this happens, I do not want my website to come out unexpectedly, and I do not want these exceptions to be swallowed silently. At least I want to process them in one place and register them. I do not want to use elmah.

Now I think we can do something like this example from here :

 TaskScheduler.UnobservedTaskException += (sender, e) => { Console.WriteLine("Saving the day! This exception would have been unobserved: {0}", e.Exception); e.SetObserved(); }; 

But, my questions are: -

  • Where to put this, can it go to Application_Start ()?
  • Will these subtle exceptions break through in Application_Error ()? If so, how do you identify them or stop them from appearing in Application_Error.

This question is similar, but there is no satisfactory answer / explanation.

0
c # asp.net-mvc-4
Aug 29 '13 at 3:42 on
source share

No one has answered this question yet.

See similar questions:

44
Fire and forget async method in asp.net mvc

or similar:

3575
How to list an enumeration?
1918
Catch a few exceptions at once?
1817
How to set up Microsoft JSON date?
818
ASP.NET website or ASP.NET web application?
799
Download ASP.NET MVC 3.0 File
611
How do you handle multiple submit buttons in the ASP.NET MVC Framework?
559
ASP.NET MVC - Setting Custom IIdentity or IPrincipal Values
537
How to create a dropdown from an enumeration in ASP.NET MVC?
481
Compile Views in ASP.NET MVC
one
Invisible handling of task exceptions with TopShelf



All Articles