Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application_Error Event Not Firing

Status
Not open for further replies.

NWChowd

Programmer
May 26, 2002
84
US
Hi,

I cannot figure out why the Application_Error event is not firing. I simply want to send an email whenever an error occurs. I don't receive any errors. it just does not fire. The C# code is below:


protected void Application_Error(Object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
string ErrorMessage = "The error description is as follows : " + Server.GetLastError().ToString();

mail.To = "user@email.com";
mail.Subject = "Error in the Site";
mail.Priority = MailPriority.High;
mail.BodyFormat = MailFormat.Text;
mail.Body = ErrorMessage;
SmtpMail.SmtpServer = "server1";
SmtpMail.Send(mail);
}

any thoughts on what I am missing??

Thanks,
DMill

======================================
"I wish that I may never think the smiles of the great and powerful a sufficient inducement to turn aside from the straight path of honesty and the convictions of my own mind."
-David Ricardo, classical economist
======================================
 
if you can debug, set a breakpoint in the first line of the Error event and see if it gets hit, otherwise instead of sending an email, try writing the content of the error to a file. in both cases, be sure that indeed the error event does not get fired and post back.

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top