Exemplo n.º 1
0
        /// <summary>
        /// 注册时生成验证码图片
        /// </summary>
        /// <param name="height"></param>
        /// <param name="width"></param>
        /// <returns></returns>
        public ActionResult RandCode(int height, int width)
        {
            if (height > 100)
            {
                height = 100;
            }

            if (width > 200)
            {
                width = 200;
            }

            string randCode = string.Join("", Randomizer.RandomArrary(10, 4));

            this.HttpContext.Session.SetString("LoginRandCode", randCode);
            byte[] imgs = null;
            using (var ms = DrawingHelper.CreateImage(randCode, height, width))
                imgs = ms.ToArray();

            return(new FileContentResult(imgs, "image/gif"));
        }