Posted on: 4/7/2014 8:25:58 PM | Views : 359

I'm trying to set up a custom errors page that will email me any errors that may occure on my website. Problem that I'm currently having is when I throw a 404, Server.GetLastError is null. Will Server.GetLastError work for a 404? Below is my code:
protected void Page_Load(object sender, EventArgs e) { Exception error = Server.GetLastError(); if (error != null) { try { MailMessage mail = new MailMessage(); mail.To.Add("receiveError@test.com"); mail.From = new MailAddress("sendError@test.com"); mail.Subject = "Error"; mail.Body = "Somebody has experienced an error " + "<br><br>"; mail.Body += error.ToString(); mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); ...

Go to the complete details ...