How I handle Exceptions in ASP.NET
Apr 29, 2024
This is my preferred method of handling errors in ASP.NET projects. Perhaps, you’ll find it useful, or maybe you’ll find holes in it and poke at it in the comments, or improve it in your own projects.
I try to not have try-catch statements in controllers, preferring to use a GlobalExceptionFilter
or whichever construct is most appropriate for the version of .NET I am using.
I have annotated the GlobalExceptionFilter
code below, providing explanations for the choices I made.