views:

3273

answers:

4

I have a grasp on this application block with ASP.NET, but I feel unsure if I am coding with it properly in ASP.NET.

I've looked all over for proper examples of how to use the Enterprise Library Exception Handling Application Block, but only turn up articles for Windows Forms.

Could somebody please point me in the right direction for usage of the Enterprise Library Exception Handling Application Block with ASP.NET? (e.g. handling exceptions in classes, when to propagate exception to Application_Error in Global.asax, how to process handled and unhandled exceptions in Application_Error).

I would really like to see what other people are doing.

Code incorporating the Enterprise Library Error Handling Application Block with the Logging Application Block would also be helpful.

Thanks!

+2  A: 

Perhaps it would be better to start with your objectives and then determine how to accomplish them.

The way our team does it is to log exceptions in the Application_Error event in global.asax. This captures all unhandled exceptions and logs them to our database. We do not use many of the features of the Exception Handling block because we haven't identified a need for them.

Ken Browning
+1  A: 

You can also try the approach and library provided in the link below

http://sites.google.com/site/spyderhoodcommunity/tech-stuff/aspnetexceptionhandlingandlogginglibrary

Exception handling block is basically for enterprise level applications. It will come with it's overheads in terms of performance as well as learning curve.

If your need is simpler, the above link will provide you the architecture to do exception handling as well as the logging library.

Kartik Sehgal
+2  A: 

Handling exceptions with the ELEHAB is basically the same in all types of application. You catch the error and call ExceptionPolicy.HandleException. The only difference is exactly where you put your "global" catch block. In WinForms, you might put it in the Main method. In ASP.NET, you might put it in the Application_Error event. In a Windows Service, you might put it in the background thread start method.

Christian Hayter
A: 

I have my own implementation, but I'm looking for input regarding its correctness.

John Bledsoe