public IActionResult GetCaptchaImage() { var code = CaptchaImage.RandomString(4); var x = new CaptchaImage(code, 250, 100); HttpContext.Session.SetString("LoginCaptcha", code); var y = ImageToByte2(x.Image); return(File(y, "image/png")); }
public ActionResult Captcha() { Session["Captcha"] = CaptchaImage.RandomString(8); var ci = new CaptchaImage(Session["Captcha"].ToString(), 200, 50, "Helvetica"); Response.Clear(); Response.ContentType = "image/jpeg"; ci.Image.Save(Response.OutputStream, ImageFormat.Jpeg); ci.Dispose(); return(null); }