user3701750
user3701750

Reputation: 217

Bot Detect Captcha Set multiple image styles

Is there a way to set multiple image style for bot detect captcha?

I am referring to this sample.

I have written an extension class to initialize captcha,

public class CaptchaHelper
{
    public static MvcCaptcha GetTicketsCaptcha()
    {
        // create the control instance
        MvcCaptcha myCaptcha = new MvcCaptcha("ExampleCaptcha");
        myCaptchaImageStyle = BotDetect.ImageStyle.AncientMosaic;
     }
}

I can set one style, but cannot find a way to set multiple options. Need some help?

Upvotes: 0

Views: 847

Answers (1)

Dhanuka777
Dhanuka777

Reputation: 8616

There is a way to do this, "CaptchaRandomization.GetRandomImageStyle" accepts ImageStyle array.

 ImageStyle[] allowedStyles =
        {
            ImageStyle.AncientMosaic, 
            ImageStyle.MeltingHeat,
            ImageStyle.MeltingHeat2,
            ImageStyle.Negative               
        };
 myCaptcha.ImageStyle = CaptchaRandomization.GetRandomImageStyle(allowedStyles);

More details

Upvotes: 1

Related Questions