<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.SessionState" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Net.Mail" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["Hits"] = 0;
Application["HitsCount"] = 0;
Application["Sessions"] = 0;
Application["TerminatedSessions"] = 0;
}
//The BeginRequest event is fired for every hit to every page in the site
protected void Application_BeginRequest(object sender, EventArgs e)
{
Application.Lock();
Application["Hits"] = (int)Application["Hits"] + 1;
Application.UnLock();
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
SmtpClient smtpClient = new SmtpClient();
string strUname = ConfigurationManager.AppSettings["smtpuser"].ToString();
string strPassword = ConfigurationManager.AppSettings["smtppass"].ToString();
smtpClient.Credentials = new NetworkCredential(strUname, strPassword);
smtpClient.Send("BlankSolution Error", "abc@abc.com", "Application Down", Server.GetLastError().Message);
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
try
{
SmtpClient smtpClient = new SmtpClient();
string strUname = ConfigurationManager.AppSettings["smtpuser"].ToString();
string strPassword = ConfigurationManager.AppSettings["smtppass"].ToString();
smtpClient.Credentials = new NetworkCredential("abc@abc.com", "JUShah12$");
smtpClient.Send("BlankSolution error", "abc@abc.com", Server.GetLastError().Message, Server.GetLastError().InnerException.StackTrace);
// Response.Redirect("~/ErrorPage/ErrorPage.aspx");
}
catch (Exception)
{
}
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Application.Lock();
Application["Sessions"] = (int)Application["Sessions"] + 1;
Application["HitsCount"] = (int)Application["HitsCount"] + 1;
Session["AdminID"] = "";
Session["AdminEmail"] = "";
Session["AdminRole"] = "";
Session["AdminFullName"] = "";
Session["CenterID"] = "";
Session["CenterName"] = "";
Application.UnLock();
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
Application.Lock();
Application["TerminatedSessions"] = (int)Application["TerminatedSessions"] + 1;
Application.UnLock();
}
</script>
No comments:
Post a Comment