-
Notifications
You must be signed in to change notification settings - Fork 1
/
Error.aspx.cs
41 lines (36 loc) · 1.42 KB
/
Error.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
namespace FlexibleTennisLeague
{
public partial class Error : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Server.GetLastError() != null)
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("[email protected]");
mailMessage.To.Add(new MailAddress("[email protected]"));
mailMessage.Subject = "FlexibleTennisLeague - Error";
Exception objErr = Server.GetLastError().GetBaseException();
string err = "Error Caught in Application_Error event\n" +
"Error in: " + Request.Url.ToString() +
"\nError Message:" + objErr.Message.ToString() +
"\nStack Trace:" + objErr.StackTrace.ToString();
mailMessage.Body = string.Format("{0}\r\n\r\n{1}", err, DateTime.Now);
Server.ClearError();
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mailMessage);
}
catch { }
}
}
}
}