Save yourself hours of debugging time in an ASP.NET web site/app.

If you are working on a web application that has added code to the Global.asax that logs and clears all unhandled exceptions, down the road in the development/maintenance unit test cycle you may forget to check that any errors have occurred during your live testing and can’t figure out why your application isn’t working correctly.  To prevent this from happening to you and other developers on your project add a Debug.Assert message just before the code that logs the unhandled exception. For example:

Debug.Assert(False, String.Format("Exception about to be logged to database:{0}", unhandledException))

Then when you are running in debug mode and an unhandled exception occurs you will get a popup like this:

No comments:

Post a Comment