protected void button1_Click(object sender, EventArgs e)
 {
     try
     {
         ImageReference.ServiceClient test = new ImageReference.ServiceClient();
         string userLength = textInput.Text;
         int    len        = int.Parse(textInput.Text); // To check whether input is an integer
         if (len <= 0 || len > 10)
         {
             Label1.Visible = true;
             Label1.Text    = "Length should be less be less than or equal to 10 and greater than 0(Zero)";
         }
         else
         {
             Session["userLength"] = userLength;    // Saving the user length in sessionvariable userLength, required by imageProcess.aspx
             string mystr = test.GetVerifierString(userLength);
             Session["generatedString"] = mystr;    // Saving the random string  in sessionvariable generatedString, required by imageProcess.aspx
             button1.Text   = "Show me another image";
             Image1.Visible = true;
         }
     }
     catch (Exception e1)
     {
         Label1.Visible = true;
         Label1.Text    = e1.Message;
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         Response.Clear();
         ImageReference.ServiceClient test1 = new ImageReference.ServiceClient();
         string mystr, userLen;
         if (Session["generatedString"] == null)
         {
             userLen = "6";                              // Assigning userLen to 6
             mystr   = test1.GetVerifierString(userLen); // Retreiving a random string
             Session["generatedString"] = mystr;         // Storing in the session variable
         }
         else
         {
             mystr = Session["generatedString"].ToString();
         }
         Stream mystream = test1.GetImage(mystr);
         System.Drawing.Image myImage = System.Drawing.Image.FromStream(mystream);  // Draw the image
         Response.ContentType = "image/jpeg";
         myImage.Save(Response.OutputStream, ImageFormat.Jpeg);
     }
     catch (Exception e1)
     {
     }
 }
Ejemplo n.º 3
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            ImageReference.ServiceClient prxy = new ImageReference.ServiceClient();
            string verify = prxy.GetVerifierString("5");

            /*Stream imgStr = prxy.GetImage(verify);
             * StreamReader reader = new StreamReader(imgStr, true);
             * string url = reader.ReadToEnd();
             * output.Text = url;*/
            Image1.ImageUrl = "http://neptune.fulton.ad.asu.edu/WSRepository/Services/ImageVerifier/Service.svc/GetImage/" + verify;


            /*var drawImg = System.Drawing.Image.FromStream(imgStr);
             * drawImg.Save("img.jpg");
             * Image1.Attributes.Add("src", "img.jpg");*/
        }