Show the visitors any friendly message and send email to you with the page name and error details.
WEBCONFIG
-----------
<customErrors mode="On" defaultRedirect="404.aspx"></customErrors>
GLOBAL.ASAX
------------
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Exception objErr = Server.GetLastError().GetBaseException();
string err = "<font face=Arial size=2><p>Error Message:" + objErr.Message.ToString() + "</p>" +
"<p>Error in: " + Request.Url.ToString() + "</p></font>";
// Email the Error
System.Net.Mail.MailMessage mlMsg = new System.Net.Mail.MailMessage("from email id", "to email id", "Subject", err);
System.Net.Mail.SmtpClient smtpCl = new System.Net.Mail.SmtpClient("xx.xx.xxx.xxx"); // IP address of the server
mlMsg.IsBodyHtml = true;
smtpCl.Send(mlMsg);
}
404.aspx
-----------
display a friendly message to the visitors, like page not found etc