Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2015-01-07
6
Medium Priority
?
247 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 400 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 1600 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

730 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