How to catch an error that is not even caught by overriding OnException?

So, we have the base controller that we use, and it contains an override for OnException, which logs the error in our error tracking tool. However, I noticed that some errors never do this, and I wonder if it’s stupid to expect the application to log all its own errors when it is an error in itself, which can cause some errors that will never be caught. .? In any case, what is the best solution, or should OnException always occur? Should I put some tool on Windows Server to report errors, and not inside the application itself?

+3
source share
2 answers

I do not think that I have ever seen a mistake that at some point was not a trap. I also register the application level and, like you, I have implemented a basic controller.

my base controller is not making any entries. instead, I created a custom action filter with which I decorate my controllers and actions, and it does all the logging.

i also added a code to the Application.Error event in global.asax that executes the logging bit and also calls the error controller to handle the actual error.

I hope this helps you in some way. If you want any of the codes I mentioned, add a comment to this answer and I will provide. this is not a lot of code.

+2
source

Controller.OnException , . , , HTTP- , OnException . , factory, RequestContext , , , .

global.asax.Application_Error "fail safe".

+2

Source: https://habr.com/ru/post/1727423/


All Articles