I am working on an application that will run in Kubernetes. Kubernetes relies on the application to know if it is healthy or not.
So, I need to know when I get a critical exception thrown. By "Critical", I mean Out of Memory, Stack Overflow, etc. Things that mean that the container should be killed.
I have seen things in ASP.Net Core that allow you to show an error page when an exception happens, but I need this to happen with both UI and Web API applications. And I don't really want it to interact with my UI at all (on the ones that have a UI ).
Is there an event (or something similar) that is raised when an exception was thrown in an ASP.Net Core application?
OutOfMemoryExceptionorStackOverflowExceptionat all in .NET. They just kill your program on the spot, even if you have error handling in place.OutOfMemoryException. I have a ASP.Net Core Web API app running in a container that I setup to have an operation that consumes memory. The operation takes a few calls to consume all the memory. After I make the few calls, it throws theOutOfMemoryException. But the other (low-memory) operations keep working fine. But a check shows that the container did not die, and is continuing to hold onto the memory. (And another call throws anotherOutOfMemoryException.)