views:

121

answers:

1

We have an ASP.NET page which uses an update panel for partial page postbacks. On the server side, the postback performs some database work and updates several UI elements. The database code is all contained in several transactions, so the state will still be consistent if an exception is thrown. We're working on some error handling code now, and my first thought was to log the exception thrown, reload the last consistent UI state, and show some sort of modal popup or other ui element with a brief error message for the user (this is an intranet page, so we're automatically notified of the bug, and the users know where to find us :)

Is this a good idea? What alternatives would be better for our end users?

+3  A: 

I would log the exception and redirect to an error page ("Sorry, we screwed up").

In most cases, I don't think it's worth complicated recovery (last consistent state). In particular cases, it may be, but mostly, not.

Note that the standard mechanisms will do most of this for you. Designate an error page, and ASP.NET will redirect there on an error. Also, unhandled exceptions will be logged by ASP.NET Health Monitoring, in the event log.

John Saunders
You could use ELMAH to log the errors too.
Scott Anderson
As far as I can tell with UpdatePanels, when the error occurs the user is only notified via a javascript error (which represents the exception) and the update doesn't complete, the page just remains as it was before the exception. Is this not redirected because of an IIS setting?
pschorf