<%@ Application Language="C#" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
    }
    
    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown
        FormsAuthentication.SignOut();
    }
        
    void Application_Error(object sender, EventArgs e) 
    {
        string strErrorMsg = "platnosci.admoto.pl Error\n\n";

        // Get the path of the page
        strErrorMsg += "Error in Path :" + Request.Path;
        // Get the QueryString along with the Virtual Path
        strErrorMsg += "\n\n Error Raw Url :" + Request.RawUrl;
        // Create an Exception object from the Last error that occurred on the server
        Exception myError = Server.GetLastError();
        // Get the error message
        strErrorMsg += "\n\nError Message :" + myError.Message;
        // Source of the message
        strErrorMsg += "\n\nError Source :" + myError.Source;
        // Stack Trace of the error
        strErrorMsg += "\n\nError Stack Trace :" + myError.StackTrace;
        // Method where the error occurred
        strErrorMsg += "\n\nError TargetSite :" + myError.TargetSite;

        // Email Error
        string strEmail = "marek.stachura@ct.com.pl";
        SendMail email = new SendMail();
        email.Wyslij(strEmail, strEmail, "platnosci.admoto.pl Error", strErrorMsg);

        Response.Redirect("Error.aspx");
    }

    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started

    }

    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.

    }
       
</script>
