public String GetCaptchaImage() { int width = 100; int height = 30; var captchaCode = _captcha.GenerateCaptchaCode(); var result = _captcha.GenerateCaptchaImage(width, height, captchaCode); HttpContext.Session.SetString("CaptchaCode", result.CaptchaCode); return(result.CaptchBase64Data); }
public IActionResult Image(string id) { if (string.IsNullOrEmpty(id)) { return(RedirectToAction(nameof(Image), new { id = Guid.NewGuid().ToString() })); } var imageData = _captchaService.GenerateCaptchaImage(id); return(File(imageData.Data, "image/png")); }
public IActionResult GetCaptchaImage() { int width = 100; int height = 36; var captchaCode = _captchaService.GenerateCaptchaCode(); var result = _captchaService.GenerateCaptchaImage(width, height, captchaCode); HttpContext.Session.SetString("CaptchaCode", result.CaptchaCode); Stream s = new MemoryStream(result.CaptchaByteData); return(new FileStreamResult(s, "image/png")); }