Thanks Lee Dumond, for this complete explanation. You explain very well. When I read ur replies I feel as if Iâm reading some bookâs article :P
Okay, Iâve this code in my Global.asax to send error details to me . I got this code from some online article and it works fine. Does it hurt if I use this along with Health Monitoring System or should I configure SimpleMailWebEventProvider with SqlWebEventProvider if I want errors/events details be send to me along with being logged in the DB?
void Application_Error(object sender, EventArgs e)
{
string strError = "Error in: " + Request.Path +
"\nUrl: " + Request.RawUrl + "\n\n";
// Get the exception object for the last error message that occured.
Exception ErrorInfo = Server.GetLastError().GetBaseException();
strError += "Error Message: " + ErrorInfo.Message +
"\nError Source: " + ErrorInfo.Source +
"\nError Target Site: " + ErrorInfo.TargetSite +
"\n\nQueryString Data:\n-----------------\n";
// Gathering QueryString information
for (int i = 0; i < Context.Request.QueryString.Count; i++)
strError += Context.Request.QueryString.Keys[i] + ":\t\t" + Context.Request.QueryString[i] + "\n";
strError += "\nPost Data:\n----------\n";
// Gathering Post Data information
for (int i = 0; i < Context.Request.Form.Count; i++)
strError += Context.Request.Form.Keys[i] + ":\t\t" + Context.Request.Form[i] + "\n";
strError += "\n";
if (User.Identity.IsAuthenticated) strError += "User:\t\t" + User.Identity.Name + "\n\n";
strError += "Exception Stack Trace:\n----------------------\n" + Server.GetLastError().StackTrace +
"\n\nServer Variables:\n-----------------\n";
// Gathering Server Variables information
for (int i = 0; i < Context.Request.ServerVariables.Count; i++)
strError += Context.Request.ServerVariables.Keys[i] + ":\t\t" + Context.Request.ServerVariables[i] + "\n";
strError += "\n";
// Sending error message to administration via e-mail
System.Web.Mail.SmtpMail.Send("
[email protected]","
[email protected]", "Error has occured", strError);
}