Reputation: 20707
I'm coming at the end of the development of my application.
Everything is working fine, but if once somebody got an unexpected exception, I would like to be able to:
What is the best way to do it with asp.net MVC?
EDIT
In complement of the great answer: I integrated elmah like described here: http://joel.net/logging-errors-with-elmah-in-asp.net-mvc-3--part-1--setup And then I specified some custom error page. So now I've all I need!
Upvotes: 0
Views: 456
Reputation: 2126
Take a look at PostSharp, neat and easy to use. Starter version available to use after free registration. NuGet package also available http://nuget.org/packages/PostSharp
Upvotes: 0
Reputation: 3428
You can catch errors in the global.asax. There is a method protected void Application_Error(object sender, EventArgs e)
where you can do what ever you want.
Upvotes: 1
Reputation: 1364
I would recommend you use "Elmah" http://code.google.com/p/elmah/
This package is a godsend - does exactly what is shown on the box, with close to ZERO changes to your source code.
It is also available via NuGet at http://nuget.org/packages/elmah
Upvotes: 2