コード例 #1
0
        /// <summary>
        /// 初始化页面
        /// </summary>
        /// <param name="e"></param>
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            string verifyCode = Game.Utils.TextUtility.CreateAuthStr(5, true);

            HttpContext.Current.Session["CheckCode"] = verifyCode;
            VerifyImageInfo verifyimg = new VerifyImageVer2().GenerateImage(verifyCode, 0, 0, Color.FromArgb(227, 227, 227), 2);
            Bitmap          image     = verifyimg.Image;

            Response.ContentType = verifyimg.ContentType;
            image.Save(Response.OutputStream, verifyimg.ImageFormat);
        }
コード例 #2
0
        /// <summary>
        /// 初始化页面
        /// </summary>
        /// <param name="e"></param>
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            string verifyCode = Game.Utils.TextUtility.CreateAuthStr(5, true);

            WHCache.Default.Save <SessionCache>(AppConfig.VerifyCodeKey, verifyCode, 5);
            VerifyImageInfo verifyimg = new VerifyImageVer2().GenerateImage(verifyCode, 0, 0, Color.FromArgb(227, 227, 227), 2);
            Bitmap          image     = verifyimg.Image;

            Response.ContentType = verifyimg.ContentType;
            image.Save(Response.OutputStream, verifyimg.ImageFormat);
        }
コード例 #3
0
        public ActionResult GetValidateCode()
        {
            string text = TextUtility.CreateAuthStr(5, true);

            WHCache.Default.Save <SessionCache>("VerifyCodeKey", text, 5);
            VerifyImageInfo verifyImageInfo = new VerifyImageVer2().GenerateImage(text, 0, 0, Color.FromArgb(227, 227, 227), 2);
            Bitmap          image           = verifyImageInfo.Image;

            byte[] fileContents = null;
            using (MemoryStream memoryStream = new MemoryStream())
            {
                image.Save(memoryStream, ImageFormat.Bmp);
                fileContents = memoryStream.GetBuffer();
                memoryStream.Close();
            }
            return(File(fileContents, "image/pjpeg"));
        }