protected virtual void AddToLog(Exception e, HttpContext context)
    {
        Exception exception = e;

        if (exception == null)
        {
            return;
        }
        if (exception is HttpUnhandledException)
        {
            exception = e.InnerException;
        }
        try
        {
            LoginUser loginUser = UserSession.LoginUser;
            if (loginUser == null)
            {
                loginUser = new LoginUser(UserSession.ConnectionString, -1, -1, null);
            }
            ExceptionLogs logs = new ExceptionLogs(loginUser);
            ExceptionLog  log  = logs.AddNewExceptionLog();
            log.URL           = context.Request.Url.AbsolutePath;
            log.StackTrace    = exception.StackTrace;
            log.Message       = exception.Message;
            log.ExceptionName = exception.GetType().Name;
            logs.Save();
        }
        catch (Exception ex)
        {
            Trace.WriteLine(ex);
        }
    }