private void ImagenCaptcha() { string codigo = GenerateRandomCode(); // Create a CAPTCHA image using the text stored in the Session object. RandomImage ci = new RandomImage(codigo, 300, 75); // Change the response headers to output a JPEG image. //Response.Clear(); //Response.ContentType = "image/jpeg"; // Write the image to the response stream in JPEG format. string imagePath = MapPath("~/Images/captcha.Bmp"); if (File.Exists(imagePath)) { File.Delete(imagePath); } ci.Image.Save(imagePath, ImageFormat.Bmp); // Dispose of the CAPTCHA image object. ci.Dispose(); // this.Image1.ImageUrl = "~/Account/CImage.ashx?codigo=" + codigo; this.Image1.ImageUrl = "~/Images/captcha.Bmp"; this.Image1.Width = 225; this.Image1.Height = 75; this.Image1.DataBind(); this.HiddenField1.Value = codigo; }
protected void Page_Load(object sender, EventArgs e) { this.Session["captcha"] = GenerateRandomCode(); RandomImage ci = new RandomImage(this.Session["captcha"].ToString(), 350, 100); this.Response.Clear(); this.Response.ContentType = "image/jpeg"; ci.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg); ci.Dispose(); }
public FileResult GetCaptchaImage() { string text = Session["CAPTCHA"].ToString(); MemoryStream ms = new MemoryStream(); RandomImage _captcha = new RandomImage(text, 220, 50); _captcha.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); _captcha.Dispose(); return(File(ms.ToArray(), "image/png")); }
public void ProcessRequest(HttpContext context) { context.Session["CaptchaImageText"] = GenerateRandomCode(); // Create a CAPTCHA image using the text stored in the Session object. RandomImage ci = new RandomImage(context.Session["CaptchaImageText"].ToString(), 300, 75); // Change the response headers to output a JPEG image. context.Response.Clear(); context.Response.ContentType = "image/jpeg"; // Write the image to the response stream in JPEG format. ci.Image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); // Dispose of the CAPTCHA image object. ci.Dispose(); }
public void ProcessRequest(HttpContext context) { context.Session["CaptchaImageText"] = GenerateRandomCode(); // Create a CAPTCHA image using the text stored in the Session object. var ci = new RandomImage(context.Session ["CaptchaImageText"].ToString(),169, 30); // Change the response headers to output a JPEG image. context.Response.Clear(); context.Response.ContentType = "image/jpeg"; // Write the image to the response stream in JPEG format. ci.Image.Save(context.Response.OutputStream, ImageFormat.Jpeg); // Dispose of the CAPTCHA image object. ci.Dispose(); }
// GET: Common public ActionResult VerificationImgForm() { string code = StringHelper.GenerateRandomCode(); RandomImage ci = new RandomImage(code, 240, 60); TempData[CaptchaImageText] = code; using (MemoryStream ms = new MemoryStream()) { ci.Image.Save(ms, ImageFormat.Jpeg); ci.Dispose(); return(File(ms.ToArray(), "image/jpeg")); } }
protected void Page_Load(object sender, EventArgs e) { // Create a random code and store it in the Session object. this.Session["CaptchaImageText"] = GenerateRandomCode(); // Create a CAPTCHA image using the text stored in the Session object. RandomImage ci = new RandomImage(this.Session["CaptchaImageText"].ToString(), 280, 56); // Change the response headers to output a JPEG image. this.Response.Clear(); this.Response.ContentType = "image/jpeg"; // Write the image to the response stream in JPEG format. ci.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg); // Dispose of the CAPTCHA image object. ci.Dispose(); }
public ActionResult GenerateCaptcha() { RandomImage randomimage = new RandomImage(); string s = randomimage.GenerateRandomCode(); Session["Captcha"] = s; FileContentResult imgstream = null; RandomImage img = new RandomImage(this.Session["captcha"].ToString(), 300, 75); var mem = new MemoryStream(); img.Image.Save(mem, System.Drawing.Imaging.ImageFormat.Jpeg); imgstream = this.File(mem.GetBuffer(), "image/Jpeg"); img.Dispose(); return(imgstream); }
public ActionResult GenerateCaptcha() { RandomImage randomimage = new RandomImage(); string s = randomimage.GenerateRandomCode(); Session[ConstantKeys.CaptchaSession] = s; FileContentResult imgstream = null; RandomImage img = new RandomImage(s, 200, 50); var mem = new MemoryStream(); img.Image.Save(mem, System.Drawing.Imaging.ImageFormat.Jpeg); imgstream = this.File(mem.GetBuffer(), "image/Jpeg"); img.Dispose(); return imgstream; }