Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        VerifyImage v    = new VerifyImage();
        string      code = v.CreateVerifyCode();

        v.CreateImageOnPage(code, this.Context);
        Response.Cookies.Add(new HttpCookie("CheckCode", code.ToUpper()));
    }
Пример #2
0
        public FileContentResult ImageValidator()
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            VerifyImage v    = new VerifyImage();
            string      code = v.CreateVerifyCode();

            CookieHelper.SaveCookie <String>("VerifyCode", code);
            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                Bitmap image = v.CreateImageCode(code);
                image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                code = CryptoManager.Encrypt(code.ToUpper());
                byte[] b = ms.GetBuffer();
                return(File(b, @"image/jpg"));
            }
        }