Beispiel #1
0
        /// <summary>
        /// 验证码
        /// </summary>
        /// <returns></returns>
        //[CheckReferrerUrl]
        public ActionResult VerifyCode(string key)
        {
            return(RunAction(() =>
            {
                if (new string[] { "login_verify", "reg_verify" }.Contains(key))
                {
                    return Http403();
                }
                var code = new DrawVerifyCode();
                byte[] bs = code.GetImageBytes();
                if (!ValidateHelper.IsPlumpList(bs))
                {
                    return Content("没有数据");
                }

                ResponseHelper.SetResponseNoCache(this.X.context.Response);
                SessionHelper.SetSession(this.X.context.Session, key, code.Code);
                return File(bs, "image/Png");
            }));
        }
Beispiel #2
0
        public void fasdfkjasldfajsdkfhasldfkj()
        {
            var codeHelper = new DrawVerifyCode();
            var path       = "d:\\data";

            new DirectoryInfo(path).CreateIfNotExist();
            for (var i = 0; i < 100; ++i)
            {
                var p = Path.Combine(path, $"data_{i}");
                new DirectoryInfo(p).CreateIfNotExist();
                for (var j = 0; j < 1000; ++j)
                {
                    var(bs, with, height) = codeHelper.GetImageBytesAndSize();
                    var f = Path.Combine(p, $"{codeHelper.Code}_{Com.GetUUID()}.png");
                    using (var fs = new FileStream(f, FileMode.Create))
                    {
                        fs.Write(bs, 0, bs.Length);
                    }
                }
            }
        }