Reputation: 3200
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!
Upvotes: 2
Views: 7594
Reputation: 31071
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.
Upvotes: 2
Reputation: 143
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.
Upvotes: 1
Reputation: 29091
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.
Upvotes: 2