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
Solved

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

Posted on 2015-01-07
6
242 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
  • 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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