1 year ago

#367802

test-img

Kyle

BotDetect ASP.Net captcha control breaks

I want to implement a Botdetect captcha control in my ASP.net MVC contact form. I followed this documentation: https://captcha.com/doc/aspnet/examples/csharp/asp.net-mvc-5.0-basic-captcha-example.html

Everything works fine, the captcha renders, and it validates the input correctly, but as I submit the form, the website breaks? And if I continue after the break, I see that the captcha was validated correctcly [![enter image description here][1]][1]

And I get the error 'Botdetect.web.mvc.pdb not loaded' I am really struggling to solve this and can't find any related errors online... Please help me...

my view:

@inherits Umbraco.Web.Mvc.UmbracoViewPage<DSG_Website.Models.ContactUs>
@using CaptchaMvc.HtmlHelpers;
@using BotDetect.Web.Mvc; 
<!--item1-->
<div class="contact-form-item contact-form-item1">

    @using (Html.BeginUmbracoForm("SaveForm", "ContactUsSurface", FormMethod.Post))
    {

        @Html.AntiForgeryToken()



        <p>First Name</p>
        <input type="text" name="FirstName" />

        <p>Last Name</p>
        <input type="text" name="LastName" />

        <p>Company</p>
        <input type="text" name="Company" />

        <p>Business Name</p>
        <input type="text" name="BusinessName" />

        <p>Phone Number</p>
        <input type="text" name="PhoneNumber" />

        <p>Job Title</p>
        <input type="text" name="JobTitle" />


        <p>Message</p>
        <textarea maxlength="500" type="text" class="large-input" name="Message"></textarea>
        @Html.Label("Retype the code from the picture:", "Retype the code below")
        {


            MvcCaptcha captcha = new MvcCaptcha("contactFormCaptcha");
            captcha.UserInputID = "CaptchaCode";

            <br />
            @Html.Captcha(captcha)
            <br />
            <br />
            <br />
            @Html.TextBox("CaptchaCode")
            @Html.ValidationMessage("CaptchaCode")
            if ((Request.HttpMethod == "POST")
                    && ViewData.ModelState.IsValid)
            {
                <span class="correct">Captcha correct!</span>
            }
            <br />


        }


        <div class="submit-frm-btn">

            <button class="contact-btn bg-mediumBlue"
                    type="submit">
                Submit
            </button>



        </div>

        <br />

        <p>@TempData["formStatus"]</p>

    }


</div>

my controller:

[HttpPost]
        [ValidateAntiForgeryToken]
        [CaptchaValidationActionFilter("CaptchaCode", "contactFormCaptcha", "Captcha incorrect")]
        public ActionResult SaveForm(ContactUs contactUsForm)
        {
            //validating captcha

            //if captcha is valid > validate contact details
            // if (contactUsForm.captchaResult.Equals("true"))
            //{

           
                if (ModelState.IsValid)
                {
                    
                    bool result = contactUsForm.saveForm(contactUsForm);

                    if (result)
                    {
                        TempData["formStatus"] = "Form submitted !";
                    }
                    else
                    {
                        TempData["formStatus"] = "Form submission unsuccessful, please try again later...";

                    }
                }
                else
                {
                    TempData["formStatus"] = "Form submission unsuccessful, invalid data";
                }
          /*  }
            else
            {
                TempData["formStatus"] = "Captcha unsuccessful";
            }*/
            


            return CurrentUmbracoPage();
        }

c#

asp.net-mvc

umbraco

captcha

0 Answers

Your Answer

Accepted video resources