コード例 #1
0
        /// <summary>
        /// 验证码
        /// </summary>
        /// <returns></returns>
        public ActionResult VerifyCode()
        {
            string vcode = CaptchaHelper.CreateRandomCode(4);

            SessionHelper.Set("vcode", vcode);

            return(File(CaptchaHelper.DrawImage(vcode), @"image/jpeg"));
        }
コード例 #2
0
        public ActionResult Vcode()
        {
            var code = CaptchaHelper.CreateRandomCode(4);

            Session["vcode"] = code;
            var img = CaptchaHelper.DrawImage(code, 20, background: Color.White);

            return(File(img, "Image/jpeg"));
        }
コード例 #3
0
ファイル: VCode.ashx.cs プロジェクト: MaxTt90/FarmMonitor
        public void ProcessRequest(HttpContext context)
        {
            string vcode = CaptchaHelper.CreateRandomCode(4);

            context.Session["img_vcode"] = vcode;
            byte[] bs = CaptchaHelper.DrawImage(vcode, 20, Color.White);
            context.Response.ContentType = "image/gif";
            context.Response.BinaryWrite(bs);
        }
コード例 #4
0
ファイル: vcode.ashx.cs プロジェクト: shoted/Online-Shop
        public void ProcessRequest(HttpContext context)
        {
            // 画布  画笔  和  素材
            var vcode = CaptchaHelper.CreateRandomCode(4);

            context.Session["user_vcode"] = vcode;
            var img = CaptchaHelper.DrawImage(vcode, 20, Color.White);

            context.Response.ContentType = "image/gif";
            context.Response.BinaryWrite(img);
        }
コード例 #5
0
ファイル: vcode.ashx.cs プロジェクト: zhanggangapp/MYBLOG
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            var code = CaptchaHelper.CreateRandomCode(4);

            context.Session["vcode"] = code;

            var img = CaptchaHelper.DrawImage(code, 20, background: Color.White);

            context.Response.ContentType = "image/gif";
            context.Response.BinaryWrite(img);
        }
コード例 #6
0
        private void SendMail(string name)
        {
            string vcode = CaptchaHelper.CreateRandomCode(6);

            CookieHelper.Set("vcode", vcode, DateTime.Now.AddHours(1));
            string content = "<html><head><title>验证码</title></head><body><div style='background:#f7f7f7;overflow:hidden'><div style='background:#fff;border:1px solid #ccc;margin:2%;padding:0 30px'><div style='line-height:40px;height:40px'>&nbsp;</div>";

            content += "<p style='margin:0;padding:0;font-size:14px;line-height:30px;color:#333;font-family:arial,sans-serif;font-weight:bold'>亲爱的用户:</p><div style='line-height:20px;height:20px'>&nbsp;</div>";
            content += "<p style='margin:0;padding:0;line-height:30px;font-size:14px;color:#333;'>您好!感谢您使用,您正在进行邮箱验证,本次请求的验证码为:</p>";
            content += "<p style='margin:0;padding:0;line-height:30px;font-size:14px;color:#333;'><b style='font-size:18px;color:#f90'>" + vcode + "</b><span style='margin:0;padding:0;margin-left:10px;line-height:30px;font-size:14px;color:#979797;'></span></p>";
            content += "<div style='line-height:80px;height:80px'>&nbsp;</div><p style='margin:0;padding:0;line-height:30px;font-size:14px;color:#333;'>系统管理员</p><p style='margin:0;padding:0;line-height:30px;font-size:14px;color:#333;'> " + DateTime.Now + " </p><div style='line-height:20px;height:20px'>&nbsp;</div></div></div></body></html>";
            try
            {
                MailHelper.Send(name, "商城验证码", content);
            }
            catch (Exception)
            {
                CookieHelper.Remove("vcode");
                Response.End();
            }
        }
コード例 #7
0
        public ActionResult GetVcode(string codelength, string codesize)
        {
            int length;

            if (!int.TryParse(codelength, out length))
            {
                return(Content(JsonReturn(Enum_ReturnStatus.失败, "验证码长度参数错误", null)));
            }
            float size;

            if (!float.TryParse(codesize, out size))
            {
                return(Content(JsonReturn(Enum_ReturnStatus.失败, "验证码字体大小参数错误", null)));
            }
            var code = CaptchaHelper.CreateRandomCode(length);

            Session["zhancaiw_vcode"] = code;
            var img = CaptchaHelper.DrawImage(code, size, background: Color.White);

            return(File(img, "Image/jpeg"));
        }