Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Error Handling

In my asp.net applications, I've typically used the Application_Error global event handler to log the error and redirect the user to a user-friendly error page.

However, I have read about ELMAH and while that seems interesting, Application_Error seems like the simpler approach.

I've read other questions where people, including myself, have suggested one way or the other. What I'm wondering is if there is any significant benefit to using one over the other and why?

like image 546
DCNYAM Avatar asked Feb 24 '09 19:02

DCNYAM


People also ask

How does ASP NET core handle global errors?

Use the UseExceptionHandler middleware in ASP.NET Core A middleware is indicated as a software component inserted into the request processing pipeline which handles the requests and responses. We can use the ASP.NET Core in-build middleware UseExceptionHandler to use as a global exception handler.

What are ASP errors?

The ASPError object is used to display detailed information of any error that occurs in scripts in an ASP page. Note: The ASPError object is created when Server. GetLastError is called, so the error information can only be accessed by using the Server. GetLastError method.


1 Answers

Elmah is a fantastic project and we use it for all of our ASP.NET applications. Not only does it log unhandled errors for you, it grabs the entire original page that the user saw, which contains a lot of detail for you.

It has email support, RSS feeds (both itemized and digest) and has an attractive console.

For 3 lines in config and a dll reference, I'd say that's a slam dunk.

like image 175
Ben Scheirman Avatar answered Oct 06 '22 21:10

Ben Scheirman