Solved

What is the best way to handle run time errors for a web application?

Posted on 2015-01-07
6
245 Views
Last Modified: 2015-01-08
Hi, I'm using vs2012, asp.net and C#.
Can you suggest or provide url for best practice nowadays to handle run time errors.  I have try catch block.  What's best to do when my application lands in the Catch block.  The best practice on how to log the error or any action I should take.  How to display errors to users.

Thank you.
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 100 total points
ID: 40536464
You should never display raw exception messages to the user. Aside from potentially being confusing, there is a chance that you could leak sensitive information about your application and/or environment.

As far as logging, you'll need to determine what your organization needs to get out of the logging. At my office, we generate an internal email with the exception details; the user gets presented with a more friendly error message that is to the point, but non-technical. You can also write exceptions to a database or a log file if you prefer. The former can be desirable in terms of maintenance/ease-of-use, but you do incur the cost of going across the network (I'm assuming a database server here, not a local database file). The latter is less desirable because files can fill up a disk, but it would be quicker than going out to a database (not that you would necessarily notice).
0
 

Author Comment

by:lapucca
ID: 40536499
I forgot to mention this is a Intranet web application.  I was thinking about sending out an email and also logging to Window's application event log.  

Can you recommend a a good url/article on how to redirect to an error message?
Thank you.
0
 
LVL 9

Accepted Solution

by:
sudheeshthegreat earned 400 total points
ID: 40537295
Few points:
Dont catch any exceptions unless you plan to do something specific with the exception
For all unexpected errors, let a shared error handler at the application level log the exceptions into the event log. A standard error page should be typically shown to the users for unhandled exceptions.
If you want to send out email alerts based on the error logs, consider doing it separately, and not as part of the error logging process itself. For instance, you could use ELMAH here

Have you read this?
http://www.asp.net/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/aspnet-error-handling
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:lapucca
ID: 40538826
Hi Sud,
Those are great suggestions.  I've been searching the internet for some documentation on how to use ELMAH and how it logs but haven't sound it. Would you happen to know where is the documentation?  Also, does it only log to database or is there an option to log to Window's application Event log?  I was also looking at "Enterprise Library - Loggin Application" in Nuget and that one seems to offer options for loggin to different destination.  Do you recommend one over the other?   Thank you.
0
 

Author Comment

by:lapucca
ID: 40538839
Okay, I found the site, https://code.google.com/p/elmah/ 
However, it looks like quite a setup for database.  I wonder if it's easier just using the Enterprise Library logging to log into the web server's window's application log?
0
 

Author Closing Comment

by:lapucca
ID: 40538875
I decided to go with Enterprise Library Logging block from MS.  I need to learn about using EL too.  thank you.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question