Example #1
0
        /// <summary>
        /// 验证码的实现
        /// </summary>
        /// <returns>返回验证码</returns>
        public ActionResult CheckCode()
        {
            //首先实例化验证码的类
            KenceryValidateCode validateCode = new KenceryValidateCode();
            //生成验证码指定的长度
            //string code = validateCode.CreateValidateCode(5);
            string code = "11111";

            //将验证码赋值给Session变量
            //Session["ValidateCode"] = code;
            this.TempData["ValidateCode"] = code;
            //创建验证码的图片
            byte[] bytes = validateCode.CreateValidateGraphic(code);
            //最后将验证码返回
            return(File(bytes, @"image/jpeg"));
        }
Example #2
0
        /// <summary>
        /// 生成验证码
        /// </summary>
        /// <returns></returns>
        public static byte[] GenerateValidateCode()
        {
            //首先实例化验证码的类
            KenceryValidateCode validateCode = new KenceryValidateCode();
            //生成验证码指定的长度
            string code = validateCode.CreateValidateCode(5);

            //string code = "11111";
            //将验证码赋值给Session变量
            //Session["ValidateCode"] = code;
            oc.CurrentUserVcode = code;
            //创建验证码的图片
            byte[] bytes = validateCode.CreateValidateGraphic(code);
            return(bytes);
            //最后将验证码返回
            //return File(bytes, @"image/jpeg");
        }