コード例 #1
0
    private void CreateYZM(HttpContext context)
    {
        // 在此处放置用户代码以初始化页面
        context.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); //不缓存
        Common.YZMHelper yz = new Common.YZMHelper();
        context.Session["validcode"] = yz.Text;                                      //将验证字符写入Session,供前台调用
        MemoryStream ms = new MemoryStream();

        yz.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
        yz.Image.Dispose();
        context.Response.ClearContent();
        context.Response.ContentType = "image/Gif";
        context.Response.BinaryWrite(ms.ToArray());
    }
コード例 #2
0
ファイル: postop.ashx.cs プロジェクト: fsfree/dookcms
 private void CreateYZM(HttpContext context)
 {
     // 在此处放置用户代码以初始化页面
     context.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); //不缓存
     Common.YZMHelper yz = new Common.YZMHelper();
     context.Session["validcode"] = yz.Text; //将验证字符写入Session,供前台调用
     MemoryStream ms = new MemoryStream();
     yz.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
     yz.Image.Dispose();
     context.Response.ClearContent();
     context.Response.ContentType = "image/Gif";
     context.Response.BinaryWrite(ms.ToArray());
 }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: rogerxing90/AHome
        //获取验证码
        public void VerifyChars()
        {
            Response.ContentType = "image/Png";
            // 在此处放置用户代码以初始化页面
            Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); //不缓存
            Common.YZMHelper yz = new Common.YZMHelper();
            yz.CreateImage();
            Session["checkcode"] = yz.Text; //将验证字符写入Session,供前台调用
            MemoryStream ms = new MemoryStream();
            yz.Image.Save(ms, ImageFormat.Png);
            //Response.ClearContent(); //需要输出图象信息 要修改HTTP头

            Response.BinaryWrite(ms.ToArray());
            yz.Image.Dispose();

            //Response.End();
            //return ms.ToArray();
        }