Example #1
0
 private CaptchaCore(CaptchaConfig captchaConfig)
 {
     _random = new Random();
     _randomFontFamily = new string[] { "arial", "arial black", "comic sans ms", "courier new", "estrangelo edessa", "franklin gothic medium", "georgia", "lucida console", "lucida sans unicode", "mangal", "microsoft sans serif", "palatino linotype", "sylfaen", "tahoma", "times new roman", "trebuchet ms", "verdana" };
     _randomColor = new Color[] { Color.Red, Color.Green, Color.Blue, Color.Black, Color.Purple, Color.Orange };
     _captchaConfig = captchaConfig;
     _text = GenerateRandomText();
     _image = RenderImage();
 }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (CaptchaConfig == null)
            {
                CaptchaConfig = new CaptchaConfig();

                CaptchaSection captchaSection = CaptchaSection.GetConfig();

                if (captchaSection != null)
                {
                    CaptchaConfig.TextChars = captchaSection.TextChars;
                    CaptchaConfig.TextLength = captchaSection.TextLength;
                    CaptchaConfig.FontWarp = captchaSection.FontWarp;
                    CaptchaConfig.BackgroundNoise = captchaSection.BackgroundNoise;
                    CaptchaConfig.LineNoise = captchaSection.LineNoise;
                }
            }

            CaptchaCore.Initialize(CaptchaConfig);

            base.OnActionExecuting(filterContext);
        }
Example #3
0
        /// <summary>
        /// Initialize the CaptchaCore.
        /// </summary>
        /// <param name="captchaConfig"></param>
        internal static void Initialize(CaptchaConfig captchaConfig)
        {
            CaptchaCore captchaCore = new CaptchaCore(captchaConfig);

            HttpContext.Current.Session.Add(_uniqueKey, captchaCore);
            HttpContext.Current.Response.Cache.SetNoStore();
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        }