user13053
user13053

Reputation: 243

Adding global exception handling to ASP.NET

I work on a rather large web site. We currently have 4 web servers and an active passive db cluster running ASP.NET 2.0 with C#. Currently our exception handling is not trapping the correct exception being thrown. I have heard it is because Server.GetLastError() is not thread safe (note: we currently do not use Server.GetLastError().GetBaseException() which might be why we are not getting the correct error).

We are starting a project to trap exact exceptions so we can actually see the root cause of the error and I’m trying to find the best way to do it.

Our options are:

So I guess my questions are:

Upvotes: 1

Views: 502

Answers (2)

Diadistis
Diadistis

Reputation: 12174

I believe that you should not alter the initial application at all. You should create and register at web.config an IHttpModule that hooks on Error event to log recursively the exception thrown and it's inner exceptions.

Further Reading:

Upvotes: 1

Andrew Rollings
Andrew Rollings

Reputation: 14571

You should take a look at Steven A. Lowe's CALM product.

It's a really nice 'plug-in' solution.

(Disclaimer: I was one of the beta-testers)

Upvotes: 0

Related Questions