Пример #1
0
        public void VerificationCode()
        {
            string vercode;

            using (Bitmap vercodeImg = VerifyCodeHelper.CreateVerifyCodeBmp(out vercode))
            {
                Session["vercode"] = vercode;
                vercodeImg.Save(Response.OutputStream, ImageFormat.Jpeg);
            }
        }
Пример #2
0
        public HttpResponseMessage Verify(string OldId, string Id)
        {
            string code;
            Bitmap bmp = VerifyCodeHelper.CreateVerifyCodeBmp(out code);

            TokenHelper.WriteVerifyToken(OldId, Id, code);
            Bitmap       newbmp = new Bitmap(bmp, 108, 36);
            MemoryStream ms     = new MemoryStream();

            newbmp.Save(ms, ImageFormat.Gif);
            byte[] data = new byte[ms.Length];
            ms.Seek(0, SeekOrigin.Begin);
            ms.Read(data, 0, Convert.ToInt32(ms.Length));
            var resp = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(data)
            };

            resp.Content.Headers.ContentType = new MediaTypeHeaderValue("image/gif");
            return(resp);
        }