I have a c# asp.net project where one ascx inherits from a base ascx. In this base ascx I would like to put a page_error method that logs the error.
I would like that if something in the derived class broke, say a null reference exception, it would not present the user with an error screen. Effectively I want every line of code to act like it is encapsulated inside it’s own try catch, so if this null ref exception happened, it would just log the error for that one line and then skip to the next line and keep going.
Is this possible, and how would I go about implementing this?
No, this is not possible. If an UnhandledException is thrown inevitably your Page_Error event will pick up the exception and the normal page execution is interrupted. In general, I think what you are trying to do is BAD practice. I wouldn’t go that route.