コード例 #1
0
        public void Index()
        {
            var    v    = new VeriCode();
            string code = v.CreateVerifyCode();

            using (var ms = new System.IO.MemoryStream())
            {
                var context = ControllerContext.HttpContext;
                using (Bitmap image = v.CreateImageCode(code))
                {
                    image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                    context.Response.ClearContent();
                    context.Response.ContentType = "image/jpeg";
                    context.Response.BinaryWrite(ms.GetBuffer());

                    image.Dispose();
                }
            }
            Session["VeriCode"] = code;
        }
コード例 #2
0
        public void Index()
        {
            var v = new VeriCode();
            string code = v.CreateVerifyCode();
            using (var ms = new System.IO.MemoryStream())
            {
                var context = ControllerContext.HttpContext;
                using (Bitmap image = v.CreateImageCode(code))
                {
                    image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                    context.Response.ClearContent();
                    context.Response.ContentType = "image/jpeg";
                    context.Response.BinaryWrite(ms.GetBuffer());

                    image.Dispose();
                }
            }
            Session["VeriCode"] = code;
        }