Putting up a site on a remote server and placing your errors in the event log won’t do you much good so I opted to place some code in Global.asax Application_Error() to email me if something went horribly wrong.
Here is what it looks like:
void Application_Error(Object sender, EventArgs e) {
Exception ex = Server.GetLastError().GetBaseException();
Exception ex = Server.GetLastError().GetBaseException();
string err = "MESSAGE: " + ex.Message +
"\nSOURCE: " + ex.Source +
"\nFORM: " + Request.Form.ToString() +
"\nQUERYSTRING: " + Request.QueryString.ToString() +
"\nTARGETSITE: " + ex.TargetSite +
"\nSTACKTRACE: " + ex.StackTrace;
try {
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage("www AT inforcesolutions.com", "wes AT inforcesolutions.com", "Web Application Error", err);
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.Send(msg);
}
catch (Exception exMail) {
}
}
"\nSOURCE: " + ex.Source +
"\nFORM: " + Request.Form.ToString() +
"\nQUERYSTRING: " + Request.QueryString.ToString() +
"\nTARGETSITE: " + ex.TargetSite +
"\nSTACKTRACE: " + ex.StackTrace;
try {
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage("www AT inforcesolutions.com", "wes AT inforcesolutions.com", "Web Application Error", err);
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.Send(msg);
}
catch (Exception exMail) {
}
}
No comments yet... Be the first to leave a reply!