public FileResult GetCaptchaImage()
 {
     CaptchaRandomImage CI = new CaptchaRandomImage();
     // here 5 means I want to get 5 char long captcha
     this.Session["CaptchaImageText"] = CI.GetRandomString(5); 
     // captcha image size and color
     CI.GenerateImage(this.Session["CaptchaImageText"].ToString(), 200, 50, Color.Black, Color.LightBlue);
     MemoryStream stream = new MemoryStream();
     CI.Image.Save(stream, ImageFormat.Png);
     stream.Seek(0, SeekOrigin.Begin);
     return new FileStreamResult(stream, "image/png");
 }
Exemple #2
0
        public FileResult GetCaptChaImage()
        {
            CaptchaRandomImage CI = new CaptchaRandomImage();

            this.Session["CaptChaImageText"] = CI.GetRandomString(5);
            CI.GenerateImage(this.Session["CaptChaImageText"].ToString(), 300, 75, Color.DarkGray, Color.White);
            MemoryStream stream = new MemoryStream();

            CI.Image.Save(stream, ImageFormat.Png);
            stream.Seek(0, SeekOrigin.Begin);
            return(new FileStreamResult(stream, "image/png"));
        }
Exemple #3
0
        public FileResult GetCaptchaImage()
        {
            CaptchaRandomImage cri = new CaptchaRandomImage();

            this.Session["CaptchaImageText"] = cri.GetRandomString(5);
            cri.GenerateImage(this.Session["CaptchaImageText"].ToString(), 300, 75, Color.DarkGray, Color.White);
            MemoryStream ms = new MemoryStream();

            cri.Image.Save(ms, ImageFormat.Png);
            ms.Seek(0, SeekOrigin.Begin);
            return(new FileStreamResult(ms, "image/png"));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CaptchaRandomImage CI          = new CaptchaRandomImage();
            string             captchatext = CI.GetRandomString(5);

            Session["CaptchaText"] = captchatext;
            CI.GenerateImage(captchatext, 200, 50, Color.DarkGray, Color.White);

            this.Response.Clear();
            this.Response.ContentType = "image/jpeg";
            CI.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg);
            CI.Dispose();
        }
Exemple #5
0
        public FileResult CaptchaImageOlustur()
        {
            CaptchaRandomImage CI = new CaptchaRandomImage();

            this.Session["GuvenlikKodu"] = CI.GetRandomString(5); //Burda güvenlik kodumuzun 5 karekter olması istedik
            CI.GenerateImage(this.Session["GuvenlikKodu"].ToString(), 300, 75, Color.DarkGray, Color.White);
            //Yukarda Güvenlik resmimizin 300x75 boyutunda olmasını ve yazının koyu gri, arkaplanıda beyaz yaptık
            MemoryStream stream = new MemoryStream();

            CI.Image.Save(stream, ImageFormat.Png);
            stream.Seek(0, SeekOrigin.Begin);
            return(new FileStreamResult(stream, "image/png"));
        }
Exemple #6
0
        public FileResult GetCaptchaImage()
        {
            CaptchaRandomImage CI = new CaptchaRandomImage();

            // here 5 means I want to get 5 char long captcha
            this.Session["CaptchaImageText"] = CI.GetRandomString(5);
            // captcha image size and color
            CI.GenerateImage(this.Session["CaptchaImageText"].ToString(), 200, 50, Color.Black, Color.LightBlue);
            MemoryStream stream = new MemoryStream();

            CI.Image.Save(stream, ImageFormat.Png);
            stream.Seek(0, SeekOrigin.Begin);
            return(new FileStreamResult(stream, "image/png"));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CaptchaRandomImage CI = new CaptchaRandomImage();

            string captchaText = CI.GetRandomString(5);

            Session["CaptchaText"] = captchaText;
            CI.GenerateImage(captchaText, 200, 50, Color.DarkGray, Color.White);

            this.Response.Clear();
            this.Response.ContentType = "image/jpeg";
            CI.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg);
            CI.Dispose();
        }
        [OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")] // This is for output cache false
        public FileResult GetCaptchaImage()
        {
            CaptchaRandomImage CI = new CaptchaRandomImage();

            this.Session["CaptchaImageText"] = CI.GetRandomString(5); // here 5 means I want to get 5 char long captcha
            //CI.GenerateImage(this.Session["CaptchaImageText"].ToString(), 300, 75);
            // Or We can use another one for get custom color Captcha Image
            CI.GenerateImage(this.Session["CaptchaImageText"].ToString(), 300, 75, Color.DarkGray, Color.White);
            MemoryStream stream = new MemoryStream();

            CI.Image.Save(stream, ImageFormat.Png);
            stream.Seek(0, SeekOrigin.Begin);
            return(new FileStreamResult(stream, "image/png"));
        }
        public FileResult GetCaptchaImage()
        {
            var    ci      = new CaptchaRandomImage();
            string captcha = ci.GetRandomString(5);

            Session["CaptchaImageText"] = captcha;
            //this.Session["CaptchaImageText"] = CI.GetRandomString(5);
            ci.GenerateImage(captcha, 300, 75, Color.DarkGray, Color.White);
            var stream = new MemoryStream();

            ci.Image.Save(stream, ImageFormat.Png);
            stream.Seek(0, SeekOrigin.Begin);
            return(new FileStreamResult(stream, "image/png "));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CaptchaRandomImage ci = new CaptchaRandomImage();
            // GetRandomString Funtion return random text of  your provided characters
            string captachaText = ci.GetRandomString(5);

            // GenearteImage funtion return image of the provided text of provided size
            //ci.GenerateImage(captachaText, 200, 50);
            // there is a overload function available for set color of the image
            Session["CaptchaText"] = captachaText;
            ci.GenerateImage(captachaText, 200, 50, Color.Red, Color.White);
            this.Response.Clear();
            this.Response.ContentType = "image/jpeg";
            ci.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg);
            ci.Dispose();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CaptchaRandomImage CI = new CaptchaRandomImage();
            //GetRandomString function returns random text of your provided characters size.
            string captchaText = CI.GetRandomString(5);

            //GenerateImage function returns image of the provided text of provided size.
            //CI.GenerateImage(captchaText, 200, 50);
            //There is an overloaded function available to set colour of the image.
            Session["CaptchaText"] = captchaText;
            CI.GenerateImage(captchaText, 280, 50, Color.DarkGray, Color.White);

            this.Response.Clear();
            this.Response.ContentType = "image/jpeg";
            CI.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg);
            CI.Dispose();
        }
        public void Captcha_Generating_Method()
        {
            CaptchaRandomImage CI = new CaptchaRandomImage();
            // GetRandomString Function return random text of your provided characters size
            string captchaText = CI.GetRandomString(4);

            //GenearteImage  function return image of the provided text of provided size
            //CI.GenerateImage(captchaText, 200, 50);
            //there is a overload function available for set color of the image
            Session["CaptchaText"] = captchaText;
            CI.GenerateImage(captchaText, 200, 50, Color.Blue, Color.AliceBlue);

            this.Response.Clear();
            this.Response.ContentType = "image/jpeg";
            CI.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg);
            CI.Dispose();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CaptchaRandomImage CI = new CaptchaRandomImage();
            //GetRandomString function returns random text of your provided characters size.
            string captchaText = CI.GetRandomString(5);

            //GenerateImage function returns image of the provided text of provided size.
            //CI.GenerateImage(captchaText, 200, 50);
            //There is an overloaded function available to set colour of the image.
            Session["CaptchaText"] = captchaText;
            CI.GenerateImage(captchaText, 280, 50, Color.DarkGray, Color.White);

            this.Response.Clear();
            this.Response.ContentType = "image/jpeg";
            CI.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg);
            CI.Dispose();
        }
Exemple #14
0
        public FileResult GetImage()
        {
            CaptchaRandomImage cr = new CaptchaRandomImage();

            HttpContext.Session.SetString("CaptchaImageText", RndStr(5));
            cr.GenerateImage(
                HttpContext.Session.GetString("CaptchaImageText"),
                140,
                30,
                Color.Orange,
                Color.White
                );
            MemoryStream ms = new MemoryStream();

            cr.Image.Save(ms, ImageFormat.Png);
            ms.Seek(0, SeekOrigin.Begin);
            return(new FileStreamResult(ms, "image/png"));
        }
        public FileResult GetCaptchaImage()
        {
            this.Session.Remove("CaptchaImageText");
            CaptchaRandomImage CI     = new CaptchaRandomImage();
            Random             random = new Random();
            //string combination = "123456789ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz";
            string        combination = "0123456789";
            StringBuilder captcha     = new StringBuilder();

            for (int i = 0; i < 4; i++)
#pragma warning disable SCS0005 // Weak random generator
            {
                captcha.Append(combination[random.Next(combination.Length)]);
            }
#pragma warning restore SCS0005 // Weak random generator
            this.Session["CaptchaImageText"] = captcha.ToString();
            CI.GenerateImage(this.Session["CaptchaImageText"].ToString(), 300, 75);
            MemoryStream stream = new MemoryStream();
            CI.Image.Save(stream, ImageFormat.Png);
            stream.Seek(0, SeekOrigin.Begin);
            return(new FileStreamResult(stream, "image/png"));
        }