コード例 #1
0
        private void setCaptcha()
        {
            CaptchaImage.Visible = true;
            ImageVerifierServiceRef.ServiceClient client = new ImageVerifierServiceRef.ServiceClient();
            verificationString = client.GetVerifierString(verifierLength);
            Stream stream    = client.GetImage(verificationString);
            Random rnd       = new Random();
            String imageName = rnd.Next(1, 10000000).ToString() + rnd.Next(100, 100000000) + ".jpg";
            string savePath  = Server.MapPath(imagePath + imageName);

            System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
            image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
            CaptchaImage.ImageUrl = "~/Images/" + imageName;
        }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         CaptchaImage.Visible = true;
         ImageVerifierServiceRef.ServiceClient client = new ImageVerifierServiceRef.ServiceClient();
         verificationString = client.GetVerifierString(verifierLength);
         Stream stream              = client.GetImage(verificationString);
         Random rnd                 = new Random();
         String imageName           = rnd.Next(1, 10000000).ToString() + rnd.Next(100, 100000000) + ".jpg";
         string savePath            = Server.MapPath(imagePath + imageName);
         System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
         image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
         CaptchaImage.ImageUrl = "~/Images/" + imageName;
     }
 }