When to override OnError?

Posted by Ek0nomik on Stack Overflow See other posts from Stack Overflow or by Ek0nomik
Published on 2010-06-10T16:38:43Z Indexed on 2010/06/10 16:42 UTC
Read the original article Hit count: 251

Filed under:
|
|

I'm looking into re-working and simplifying our error handling in an application I support. We currently have all of our pages inheriting from a base class we created, which in turn obviously inherits from System.Web.UI.Page. Within this base class, the OnError method is currently being overridden, and in turn calling MyBase.OnError, and then calling one of our custom logging methods.

I don't see any benefit of overriding the OnError method, and I think it would be better to let the Application_Error method in the Global.asax take care of the unhandled exception (logging it) and then the customErrors section in the config would trigger a process to redirect the user.

Looking online it looks like people override this method quite frequently, but I don't see a need to and this article from MSDN makes me think the same.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about page-lifecycle