예제 #1
0
        /// <summary>
        /// 验证码
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult GetCodeImg(double?id)
        {
            string code = new ValidataCode().GetCode(4);

            Session["code"] = code;
            Session.Timeout = 10;
            byte[] img = new ValidataCode().CreateValidateGraphic(code);
            return(File(img, @"img/jpeg"));
        }
예제 #2
0
        public ActionResult ShowCode(double?id)
        {
            ValidataCode valideataCode = new ValidataCode();
            string       strcode       = valideataCode.getCode(4);

            Session["code"] = strcode;
            byte[] imgBytes = valideataCode.CreateValidateGraphic(strcode);
            return(File(imgBytes, @"img/jpeg"));
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "image/gif";
            string code = ValidataCode.CreateRandomCode(4);

            ///验证码放入session
            context.Session["vCode"] = code;
            byte[] img = ValidataCode.DrawImage(code, 20, background: Color.White);
            context.Response.BinaryWrite(img);
        }