Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 18, 2008 06:09 PM by sambeetpatra
Jul 01, 2005 03:17 PM|LINK
I am frequently asked the best way to capture web application's unhandled exceptions that occur at a web host provider and without providing customers visibility to errors?
The best way to capture web application bugs in a web host provider environment without providing error information to your users is to email the unhandled exception to a web administrator as follows:
protected void Application_Error( Object sender, EventArgs e)
if (System.Web.HttpContext.Current.Request.Url.Authority != "localhost")
// Get the Exception object wrapped in the InnerException property
Exception unhandledException =
// Create a MailMessage
System.Web.Mail.MailMessage mail= new System.Web.Mail.MailMessage();
mail.From = "firstname.lastname@example.org";
mail.To = "email@example.com";
mail.BodyFormat = System.Web.Mail.MailFormat.Text;
mail.Subject = "unHandledException.Message";
mail.Body = unhandledException.ToString();
// Send the email
// Redirect the user to a maintenence page
This page is currently being worked on by our technical support staff
and is unavailable. Please check back at a later time.
This code will e-mail exception details to the administrator and allow the user to know the page is being worked on. The exception will display as normal on the localhost.
Jun 11, 2008 03:25 PM|LINK
I prefer to use the enterprise library to catch the exception and log to database.
Then I make a page in admin to present errors.
Jun 19, 2008 03:14 PM|LINK
What’s the enterprise library? [*-)]
As I use a similar way to
MLibby but also get user ip/details etc
Always interested in a different way[:)]
Jun 19, 2008 06:01 PM|LINK
enterprise library ( also known as microsoft patterns and practices) is a library of application blocks designed to assist developers with common enterprise development challenges
Here is a link:
Jul 15, 2008 01:16 AM|LINK
This looks good.
Jul 18, 2008 06:09 PM|LINK
I usually follow a number of logging options other than emails. The problem with emails is that there may not be a guarantee of delivery for several reasons [spams / smtp servie issues etc]. You can consider using any of these options instead
(a) Write to a file. THere are issues with it as it requires access to file system. Also make sure you use a roll up mechanism so that the file does not overgrows.
(b) Save in the database. This makes it feasible to build up an interface to view error details.
(c) Post to event viewer.
Also, no matter what option you choose, consider using a utility like log4net which makes these options configurable.