示例#1
0
        public CaptchaResultModel GetCaptcha()
        {
            var randomValue = CaptchaHelper.GetValidateCode(5);
            var imageData   = CaptchaHelper.CreateBase64Image(randomValue);
            var key         = Guid.NewGuid().ToString();

            _cachingProvider.Set(key, randomValue, TimeSpan.FromMinutes(2));
            return(new CaptchaResultModel(key, imageData));
        }
示例#2
0
        public async Task <CaptchaResultModel> GetCaptcha()
        {
            var randomValue = CaptchaHelper.GetValidateCode(5);
            var imageData   = CaptchaHelper.CreateBase64Image(randomValue);
            var key         = Guid.NewGuid().ToString();
            await _cachingProvider.SetAsync(key, randomValue, TimeSpan.FromMinutes(2));

            return(new CaptchaResultModel
            {
                CaptchaKey = key,
                CaptchaData = imageData
            });
        }