All applications require error handling to run smoothly. Luckily, there are plenty of options that you can choose from. With so many services out on the market though, how do you decide which error handling service is best for your apps?
There are some crucial things that we’ll look at in this article, but if you are hunting for something extra-ordinary then consider going with MVC error handling services.
There are two critical, key factors that any app owner needs to accomplish when handling errors. First and foremost, they need to be handled gracefully by showing users a friendly looking error page. Secondly, the errors themselves need to be logged so that you are not only aware of them but can monitor them at as well.
Simple enough, right? MVC offers five methods for handling application error when they occur to get your app back up and running. Those are:
Web.Config custom errors
MVC Handle Error Attribute
Controller On Exception method
Http Application Error event
Collect exceptions via .NET profiling with retrace
Let’s take a closer look at each of those.
When your users see the dreaded ASP.NET error screen, that’s bad news and minimal return rates. You need to have a custom error page in your Web.Config that looks good and conveys a friendly message. Otherwise, they may cease to use your application altogether.
MVC HandleErrorAttribute ?
This feature can be applied to an entire controller as well as individual controller action methods. It can also handle 500 level errors that happen within an MVC action method. Now, that doesn’t include exceptions outside of the MVC pipeline, such as other HTTP modules, making impractical for any global unhandled error handlers.
Outside of that realm, it does work perfectly when it comes to tailoring specific error pages for MVC controllers and action methods. Specifying the error in your Web.Config
MVC Controller OnException?
Similar to HandleErrorAttribute, MVC Controller offers up a greater level of flexibility. Working with all HTTP status codes, handling over 500 level responses, and giving you the ability to log errors makes this a crucial feature. When you’re looking to provide your users with custom MVC views and log exceptions, OnException is the way to go.
This feature provides a simple way for you to log every single unhandled exception. All it takes is basic error logging code, and you can monitor them all. This is one you’ll want to use continuously since it helps you stay on top of errors when they occur.
This is where Retrace comes into play. Tapping into the .NET profiling API’s, it tracks the performance of your app all the way down to its code level. Thus, it automatically collects all unhandled expections and can be configured to receive every exception ever thrown.
That means the ones that are handled and discarded as well. The best part, it requires zero code changes. In combination with HttpApplication, there’s no better way to be on top of errors when they occur.
So, Why MVC??
Well, it allows you to handle errors in five effective ways. Those are:
Specifying a default error page via Web.Config
Gain expert control over how error type messages are displayed with HandleErrorAttribute and OnException
Track every single error with HttpApplication and Collect.NET
Offers Retrace and other error monitoring features
Allows you to view all exceptions on your workstation for free with Prefix
If you’re looking for expert error monitoring, then consider using MVC.
[Written by External Partner]