public IActionResult Verify()
        {
            var code  = _verifyCodeHelper.CreateVerifyCode(VerifyCodeHelper.VerifyCodeType.AbcVerifyCode);
            var image = _verifyCodeHelper.CreateByteByImgVerifyCode(code, 116, 36);

            HttpContext.Session.SetString("verify", code);
            return(File(image, @"image/jpeg"));
        }
Esempio n. 2
0
        public ActionResult GetVerifyCode()
        {
            var verify = VerifyCodeHelper.CreateVerifyCode();
            var stream = new MemoryStream();

            verify.Bitmap.Save(stream, ImageFormat.Png);
            return(File(stream.ToArray(), @"image/png"));//返回FileContentResult图片
        }
Esempio n. 3
0
        /// <summary>
        /// 验证码  直接写入Response
        /// </summary>
        public void Verify()
        {
            string code   = "";
            Bitmap bitmap = VerifyCodeHelper.CreateVerifyCode(out code);

            base.HttpContext.Session["CheckCode"] = code;
            bitmap.Save(base.Response.OutputStream, ImageFormat.Gif);
            base.Response.ContentType = "image/gif";
        }
Esempio n. 4
0
        public ActionResult GetVerifyCode()
        {
            VerifyCodeHelper verify     = new VerifyCodeHelper();
            string           verifyCode = verify.CreateVerifyCode(4);

            Session["VerifyCode"] = verifyCode;

            byte[] graphicByte = verify.CreateGraphic(verifyCode);
            return(File(graphicByte, @"image/jepg"));
        }
Esempio n. 5
0
        /// <summary>
        /// httphandler
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            //在此处写入您的处理程序实现。
            string code   = "";
            Bitmap bitmap = VerifyCodeHelper.CreateVerifyCode(out code);

            context.Session["CheckCode"] = code;
            bitmap.Save(context.Response.OutputStream, ImageFormat.Gif);
            context.Response.ContentType = "image/gif";
        }
Esempio n. 6
0
        public string BuildValidCode()
        {
            VerifyCodeHelper v = new VerifyCodeHelper();

            v.CodeSerial = "0,1,2,3,4,5,6,7,8,9";
            v.Length     = 6;
            string code = v.CreateVerifyCode(); //取随机码

            return(code);
        }
Esempio n. 7
0
        /// <summary>
        /// 验证码 FileContentResult
        /// </summary>
        /// <returns></returns>
        public ActionResult VerifyCode()
        {
            string code   = "";
            Bitmap bitmap = VerifyCodeHelper.CreateVerifyCode(out code);

            base.HttpContext.Session["CheckCode"] = code;
            MemoryStream stream = new MemoryStream();

            bitmap.Save(stream, ImageFormat.Gif);
            return(File(stream.ToArray(), "image/gif"));//返回FileContentResult图片
        }
Esempio n. 8
0
        public ActionResult Verify(int random)
        {
            string code   = "";
            Bitmap bitmap = VerifyCodeHelper.CreateVerifyCode(out code);

            base.HttpContext.Session.SetString("CheckCode", code);
            MemoryStream stream = new MemoryStream();

            bitmap.Save(stream, ImageFormat.Gif);
            return(File(stream.ToArray(), "image/gif"));
        }
Esempio n. 9
0
        public FileContentResult VerifyCode()
        {
            string code   = "";
            var    bitMap = VerifyCodeHelper.CreateVerifyCode(out code);

            HttpContext.Session["CheckCode"] = code;
            var stream = new MemoryStream();

            bitMap.Save(stream, ImageFormat.Gif);
            return(File(stream.ToArray(), "image/gif"));
        }
Esempio n. 10
0
        public ActionResult GetImgVerifyCode(string name)
        {
            VerifyCodeHelper v = new VerifyCodeHelper();

            v.CodeSerial = "0,1,2,3,4,5,6,7,8,9";
            string code = v.CreateVerifyCode();                       //取随机码

            v.CreateImageOnPage(code, ControllerContext.HttpContext); //输出图片
            Session[name] = code;                                     //Session 取出验证码
            Response.End();
            return(null);
        }
        public IActionResult Index()
        {
            (Bitmap bp, string code) = VerifyCodeHelper.CreateVerifyCode();

            string encryptCode = DESEncryptHelper.EncryptDES(code);

            WebHelper.WriteCookie("VerifyCode", encryptCode, 30);

            MemoryStream stream = new MemoryStream();

            bp.Save(stream, ImageFormat.Png);
            return(File(stream.ToArray(), @"image/png"));//返回FileContentResult图片
        }
Esempio n. 12
0
        public ActionResult VerifyCode()
        {
            string verifyCode = string.Empty;
            Bitmap bitmap     = VerifyCodeHelper.CreateVerifyCode(out verifyCode);

            #region 缓存Key
            Cache cache = new Cache();
            // 先用当前类的全名称拼接上字符串 “verifyCode” 作为缓存的key
            var verifyCodeKey = $"{this.GetType().FullName}_verifyCode";
            cache.Remove(verifyCodeKey);
            cache.Insert(verifyCodeKey, verifyCode);
            #endregion
            MemoryStream memory = new MemoryStream();
            bitmap.Save(memory, ImageFormat.Gif);
            return(File(memory.ToArray(), "image/gif"));
        }