public IActionResult GetCheakCode() { CheakCode cheakcode = new CheakCode(); var img = cheakcode.GetImgWithValidateCode(out string code); Session.SetString(nameof(CheakCode), code); return(File(img.ToArray(), "image/Gif")); }
public void CheakCode() { for (int i = 0; i < 10; i++) { CheakCode cheakCode = new CheakCode(); using (var validateImageData = cheakCode.GetImgWithValidateCode(out string code)) { using (Image image = Image.FromStream(validateImageData)) { image.Save($@"d:\ss{i}.Jpeg", ImageFormat.Jpeg); } } } }
protected ResponseResult VCheakCode(string code) { if (code.IsNullOrEmpty()) { return(ResponseResult.Failed("图形验证码不能为空 ")); } if (Session == null) { return(ResponseResult.Failed("请刷新浏览器 ")); } if (CheakCode == null) { return(ResponseResult.Failed("图形验证码不正确")); } if (!CheakCode.Equals(code)) { return(ResponseResult.Failed("图形验证码不正确")); } Session.SetString(nameof(CheakCode), string.Empty); return(ResponseResult.Success()); }