Esempio n. 1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(Recaptcha1.Response))
            {
                lblMessage.Text = "Captcha cannot be empty.";
            }
            else
            {
                var result = Recaptcha1.Verify();

                if (result.Success)
                {
                    Response.Redirect("Welcome.aspx");
                }
                else
                {
                    lblMessage.Text = "Error(s): ";

                    foreach (var err in result.ErrorCodes)
                    {
                        lblMessage.Text = lblMessage.Text + err;
                    }
                }
            }
        }
Esempio n. 2
0
    async protected void RegisterNewUser(object sender, EventArgs e)
    {
        if (Password.Text != Reenter.Text)
        {
            Message.Text  = "The passwords do not match. Re-enter the passwords.";
            Password.Text = "";
            Reenter.Text  = "";
            return;
        }

        try
        {
            if (Useremail.Text == "" || Username.Text == "" || Password.Text == "" || Reenter.Text == "" || FirstName.Text == "" || LastName.Text == "")
            {
                Message.Text = "None of the values can be empty.";
                return;
            }


            var exists = CheckIfUserAlreadyExists(Useremail.Text);

            if (exists)
            {
                Message.Text = "You already have an account. Go back and login!";
                return;
            }

            if (String.IsNullOrEmpty(Recaptcha1.Response))
            {
                Message.Text = "Captcha cannot be empty.";
                return;
            }
            else
            {
                RecaptchaVerificationResult result = await Recaptcha1.VerifyTaskAsync();

                if (result == RecaptchaVerificationResult.Success)
                {
                    StoreData(Username.Text, Password.Text, "Member", FirstName.Text, LastName.Text, Useremail.Text);

                    Message.Text   = "Registration complete.";
                    GoBack.Visible = true;
                    return;
                }
                else if (result == RecaptchaVerificationResult.IncorrectCaptchaSolution)
                {
                    Message.Text = "Incorrect captcha response.";
                }
                else
                {
                    Message.Text = "Some other problem with captcha.";
                }
            }
        }
        catch (Exception exception)
        {
            Message.Text = "Could not register. Try again." + exception;
        }
    }
Esempio n. 3
0
 protected async void btnSubmit_Click(object sender, EventArgs e)
 {
     if (await Recaptcha1.VerifyIfSolvedAsync())
     {
         Response.Redirect("Welcome.aspx");
     }
     else
     {
         lblMessage.Text = "Incorrect CAPTCHA response.";
     }
 }
Esempio n. 4
0
    protected void InviaButton_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(Recaptcha1.Response))
        {
            lblMessage.Text = "Inserire codice reCaptcha in basso";
        }
        else
        {
            RecaptchaVerificationResult result = Recaptcha1.Verify();

            if (result == RecaptchaVerificationResult.Success)
            {
                ////Preparo i campi della mail
                String from = "*****@*****.**";
                String to   = "*****@*****.**";
                //Istanzio la classe che rappresenta il messaggio
                MailMessage mMailMessage = new MailMessage();
                //Aggiungo il Mittente
                mMailMessage.From = new MailAddress(from);
                //Aggiungo il destinatario
                mMailMessage.To.Add(new MailAddress(to));
                mMailMessage.To.Add(new MailAddress("*****@*****.**"));
                //L'oggetto
                mMailMessage.Subject = "Richiesta informazioni da sito web";
                //Il corpo
                mMailMessage.Body = "Richiesta di informazioni ricevuta tramite il sito www.santuariodicaravaggio.eu<br/><br/><strong>Messaggio inviato da:</strong> " + NomeTextBox.Text + " " + CognomeTextBox.Text + "<br/><strong>Mail:</strong> " + MailTextBox.Text + "<br/><strong>Tel:</strong> " + TelTextBox.Text + "<br/><br/><strong>Testo del messaggio:</strong> <br/>" + RichiestaTtBox1.Text;
                //Setto la modalità testo, per il contenuto del messaggio. Sarebbe possibile inviare anche dell'HTML mettendo true
                mMailMessage.IsBodyHtml = true;
                //Setto la priorità
                mMailMessage.Priority = MailPriority.Normal;
                //configurazione nel web.config
                SmtpClient mSmtpClient = new SmtpClient();
                //Invio il messaggio
                mSmtpClient.Send(mMailMessage);
                Response.Redirect("FormResponse.aspx");
            }
            if (result == RecaptchaVerificationResult.IncorrectCaptchaSolution)
            {
                lblMessage.Text = "reCaptcha inserito in modo scorretto";
            }
            else
            {
                lblMessage.Text = "C'è stato un problema, riprova.";
            }
        }
    }
        protected async void btnSubmit_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(Recaptcha1.Response))
            {
                lblMessage.Text = "Captcha cannot be empty.";
            }
            else
            {
                RecaptchaVerificationResult result = await Recaptcha1.VerifyTaskAsync();

                if (result == RecaptchaVerificationResult.Success)
                {
                    Response.Redirect("Welcome.aspx");
                }
                if (result == RecaptchaVerificationResult.IncorrectCaptchaSolution)
                {
                    lblMessage.Text = "Incorrect captcha response.";
                }
                else
                {
                    lblMessage.Text = "Some other problem with captcha.";
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Método para enviar el correo electrónico
        /// </summary>
        /// <param name="titulo"></param>
        /// <param name="nombre"></param>
        /// <param name="correo"></param>
        /// <param name="mensaje"></param>
        private void Enviar(string titulo, string nombre, string correo, string mensaje)
        {
            if (String.IsNullOrEmpty(Recaptcha1.Response))
            {
                lblAviso.Text = "El código captcha no puede estar vacío.";
            }
            else
            {
                RecaptchaVerificationResult result = Recaptcha1.Verify();

                if (result == RecaptchaVerificationResult.Success)
                {
                    string      to   = ConfigurationManager.AppSettings["To"];
                    MailMessage mail = new MailMessage();
                    mail.To.Add(new MailAddress(to));
                    mail.From    = new MailAddress(correo, nombre);
                    mail.Subject = titulo + " " + correo;
                    mail.Body    = mensaje + "\n\n" + nombre + "\n" + correo;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Send(mail);
                    Limpiar();
                    lblAviso.Text = "Mensaje enviado. Gracias por su tiempo.";
                }
                else
                {
                    if (result == RecaptchaVerificationResult.IncorrectCaptchaSolution)
                    {
                        lblAviso.Text = "El códifo de verificacion es incorrecto.";
                    }
                    else
                    {
                        lblAviso.Text = "Ha ocurrido un error al reconocer el código captcha.";
                    }
                }
            }
        }