Implement exception handling in ASP.NET 3.5

I would like to implement exception handling in an ASP.NET application. How do you suggest me to realize this? Some requirements:

  • The user should see a friendly page when an exception occurs.
  • Administrator should receive an email with details about the exception

I understand that there are several ways to implement exceptions (for example: log messages in the event viewer)

What is the recommended approach?

+4
source share
3 answers

The recommended approach really depends on what you need to do with the error information.

For simple applications, just configure the web.config file to redirect to a friendly page with an error.

It is generally recommended that you write raw error data to a database, file, Windows application log, or web service, processing it using the Global.asax Application_Error event. You can also use web.config to get your friendly page with this. As a rule, I would not recommend using Windows error logs, since they are usually a little dumb, but there is nothing wrong with that.

Tools such as log4net are widely used to get very detailed information about work, including warnings and informational messages. You usually go on this route for products or applications at the enterprise level, where your support groups need as much information as possible to diagnose errors.

MSDN has some basic error handling settings and what you can do with them.

+2
source

I wrote an article about this, I think you will really like it

http://dotnetblogger.com/post/2008/12/03/ASPNET-Health-Monitor.aspx

As for the friendly page bit, I just use the built-in exception handling in web.config ... since you are implementing unknown exception material in global.asax

You can also handle exceptions in try / catch blocks and add a note to it if you want. Then just bind the database to a good gridview for administrators to see errors easily.

+2
source

I have a nice reusable HttpModule which you can see here here . It can be easily used to eliminate the Exceptions that occur during normal user requests, and those that occur in the background thread.

0
source

Source: https://habr.com/ru/post/1299281/


All Articles