ReCaptcha in Custome Page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
I am in the process of putting together a custom tec support page that links in to sage CRM, I like to be able to use the ReCaptcha on that page to stop spamming how do I go about integrating it in to a new page.

ta
11 years ago
How did you implement the page? As a topic? :)
11 years ago
No I am building the page from scratch... as it links in to other custom sections I have built to pull data.

I have got the page to display the caption but it not validating... It still allowing it through there the code I am using

[HttpPost, ActionName("SupportRequest")]
        [CaptchaValidator]
        public ActionResult RequestSupport(FormCollection collection, bool captchaValid)
        {


            if (captchaValid == false)
            {
                RedirectToAction("/SupportRequest");
            }

            TechSupportRequest Ntool = new TechSupportRequest();

            //Read the config file.....
            Ntool.readfile();

            //ProductVersions = collection["Searchstring"];

            Ntool.Name = collection["Name"];
            Ntool.Organisation = collection["Organisation"];
            Ntool.Address = collection["Address"];
            Ntool.City = collection["City"];
            Ntool.County = collection["County"];
            Ntool.Postcode = collection["Postcode"];
            try
            {
                Ntool.CountryRegion = long.Parse(collection["Country"]);
            }
            catch
            {
                Ntool.CountryRegion = 0;
            }
            Ntool.Email = collection["Email"];
            try
            {
                Ntool.WhichProduct = long.Parse(collection["LucidProducts"]);
            }
            catch
            {
                Ntool.WhichProduct = 0;
            }
            try
            {
                Ntool.Version = long.Parse(collection["ProductVersions"]);
            }
            catch
            {
                Ntool.Version = 0;
            }
            Ntool.SerialNo = collection["SRNO"];
            Ntool.DescriptionofProblem = collection["Problem"];
            Ntool.AddRecord();
            return View();
        }

Don't worry about Ntool that a component I have built to store the data so that it can be drop in to Sage CRM at a later point.  

The bit I am having problem with is

if (captchaValid == false)
            {
                RedirectToAction("/SupportRequest");
            }

It allow any thing through, it either erroring or just allowing stuff through.

Help!!!
11 years ago
So you have included

Html.GenerateCaptcha()


in your view, and enclosed them in the FORM tag; and setup the reCaptcha key properly at the backend, and still it is not validating? :)
11 years ago
I am putting that on the page and it is generating the caption on the page.

But when I call the post back code it not executing the check, it adding the values to the DB and then sending the person to the thanks page with out checking the caption.
11 years ago
Sorry it was me been a numpty it checking the value but I forgot to do the redirect correctly.  

so the correct code should be....

[HttpPost]
        [CaptchaValidator]
        public ActionResult RequestSupport(FormCollection collection, bool captchaValid)
        {

            if (captchaValid==false)
            { Action if false}
action if true
}

Well at lest I have it working that one less problem I have to worry about.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.