Example #1
0
        public ActionResult Captcha()
        {
            string code = ValidateHelper.CreateValidateCode(5);

            _session.SetString("ValidateCode", code);
            byte[] bytes = ValidateHelper.CreateValidateGraphic(code);
            return(File(bytes, @"image/jpeg"));
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string Code;
            var    ms = ValidateHelper.CreateValidateGraphic(out Code, 6, 200, 50, 10);

            //将生成的图片发回客户端
            //RequeryToModeltext页面中引用
            Response.ClearContent(); //需要输出图象信息 要修改HTTP头
            Response.ContentType = "image/Png";
            Response.BinaryWrite(ms.ToArray());
        }