Global.asax

    void Application_Error(object sender, EventArgs e)
    {
          
//  Code that runs on application shutdown

        
Exception ex Server.GetLastError().GetBaseException();

         
// olusumum tarihini getir
        
string dateTime DateTime.Now.ToLongDateString() + ", at "
                            
+ DateTime.Now.ToShortTimeString();

        string 
errorMessage "Exception generated on " + dateTime;
        
// hatanin olustusgu url
        
System.Web.HttpContext context System.Web.HttpContext.Current;
        
errorMessage +"\n\n Page location: " + context.Request.RawUrl;      
        
errorMessage +"\n\n Message: " + ex.Message;
        
errorMessage +"\n\n Source: " + ex.Source;
        
errorMessage +"\n\n Method: " + ex.TargetSite;
        
errorMessage +"\n\n Stack Trace: \n\n" + ex.StackTrace;
        string 
from Configuration.AdminMail;
        string 
to Configuration.ErrorMailAddress;
        string 
subject " Error Report";
        string 
body errorMessage;
        
SendMail(from, to, subject, body);
            
        
Server.ClearError();
        
Response.Redirect("GenericErrorPage.aspx"true);
    
}