示例#1
0
        /// <summary>
        /// 【生成修改个人信息的验证码图片】
        /// </summary>
        /// <returns></returns>
        public void CreateCheckCode()
        {
            CreateCheckCode code   = new CreateCheckCode();    //创建一个验证码对象
            String          number = code.GenerateCheckCode(); //获取随机码

            Session.Add("UpdateInfo_Code", number);            //保存到Session

            byte[] fileContents = code.CreateCheckCodeImage(number);

            //Stream ms = new MemoryStream(fileContents);
            //return ms;
            Response.ClearContent();
            Response.ContentType = "image/Gif";
            Response.BinaryWrite(fileContents);
        }
示例#2
0
        /// <summary>
        /// 【根据验证码类似生成验证码并保存到session中】
        /// </summary>
        /// <param name="codeType">【验证码类型】</param>
        private void CreateCode(string codeType)
        {
            try
            {
                CreateCheckCode code   = new CreateCheckCode();    //创建一个验证码对象
                String          number = code.GenerateCheckCode(); //获取随机码
                Session.Add(codeType, number);                     //保存到Session

                byte[] fileContents = code.CreateCheckCodeImage(number);

                //Stream ms = new MemoryStream(fileContents);
                //return ms;
                Response.ClearContent();
                Response.ContentType = "image/Gif";
                Response.BinaryWrite(fileContents);
            }
            catch
            {
                RedirectToAction("../User/_404");
            }
        }