-
Notifications
You must be signed in to change notification settings - Fork 1
/
Global.asax.cs
80 lines (63 loc) · 2.59 KB
/
Global.asax.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Net.Mail;
using DLL;
namespace FlexibleTennisLeague
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
}
protected void Session_Start(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
// Code that runs when a new session is started
HttpContext context = HttpContext.Current;
HttpRequest request = context.Request;
if (request.Url.AbsoluteUri.StartsWith("http://flexibletennisleague.com"))
{
Response.StatusCode = 301;
Response.Redirect(request.Url.AbsoluteUri.Replace("http://flexibletennisleague.com", "http://www.flexibletennisleague.com"), true);
}
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
if (Server.GetLastError() != null)
{
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();
if (HttpContext.Current.Request.UrlReferrer != null)
err += string.Format("\r\nRequest URI : {0}", HttpContext.Current.Request.UrlReferrer.AbsoluteUri);
mailMessage.Body = string.Format("{0}\r\n\r\n{1}", err, DateTime.Now);
//Server.ClearError();
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mailMessage);
////Response.Redirect("~/Error.aspx");
}
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
StoredData.CleanUp();
}
}
}