예제 #1
0
        /// <summary>
        /// 获取验证码图像流
        /// </summary>
        /// <returns></returns>
        public static MemoryStream GetImageStream()
        {
            string checkCode = Character.RandomString("num", 4);

            System.Web.HttpContext.Current.Session["verifyCode"] = checkCode;
            return(VerifyCodeHelper.GetImageStream(checkCode, 100, 40, Color.White, 1));
        }
예제 #2
0
 /// <summary>
 /// 获取验证码图像
 /// </summary>
 public static void ResponseImage()
 {
     using (MemoryStream ms = VerifyCodeHelper.GetImageStream())
     {
         System.Web.HttpContext.Current.Response.ClearContent();
         System.Web.HttpContext.Current.Response.ContentType = "image/Png";
         System.Web.HttpContext.Current.Response.BinaryWrite(ms.ToArray());
     }
 }
예제 #3
0
        /// <summary>
        /// 获取验证码图像
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="bgcolor"></param>
        /// <param name="textcolor"></param>
        public static void ResponseImage(int width, int height, Color bgcolor, int textcolor)
        {
            string checkCode = Character.RandomString("num", 4);

            System.Web.HttpContext.Current.Session["verifyCode"] = checkCode;
            using (MemoryStream ms = VerifyCodeHelper.GetImageStream(checkCode, 100, 40, Color.White, 1))
            {
                System.Web.HttpContext.Current.Response.ClearContent();
                System.Web.HttpContext.Current.Response.ContentType = "image/Png";
                System.Web.HttpContext.Current.Response.BinaryWrite(ms.ToArray());
            }
        }