我在.net程序裡用了一個asp(code.asp) 的驗證碼因code.asp傳過來的 Session值是Session("checkcode")--是園擴號
這個Session在.net程序裡可以用嗎??不能用的話是不是還要寫個.net的驗證碼??

解决方案 »

  1.   

    asp的驗證碼比較漂亮..所以最好就用這個版本的
      

  2.   

    我有验证码。。HOHOH.................
    独家开创的。。
      

  3.   

    ASP.net的session和asp的session要共用好象要配置下具体你查查网上资料哈
      

  4.   

    aspx下的验证码类比较多用的也很方便,asp存在seeion中的值是否可用楼主可以试一下,如果不行的话,可以放在cookie中,这样应该可以用aspx读取
      

  5.   

    我剛好也在做這個,代碼給你可以直接用的 protected void Page_Load(object sender, EventArgs e)
        {
            string checkCode = CreateRandomCode(6);
            Session["CheckCode"] = checkCode;
            CreateImage(checkCode);
        }
        private string CreateRandomCode(int codeCount)
        {
            string allChar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,W,X,Y,Z";
            string[] allCharArray = allChar.Split(',');
            string randomCode = "";
            int temp = -1;        Random rand = new Random();
            for (int i = 0; i < codeCount; i++)
            {
                if (temp != -1)
                {
                    rand = new Random(i * temp * ((int)DateTime.Now.Ticks));
                }
                int t = rand.Next(35);
                if (temp == t)
                {
                    return CreateRandomCode(codeCount);
                }
                temp = t;
                randomCode += allCharArray[t];
            }
            return randomCode;
        }
        private void CreateImage(string checkCode)
        {
            int iwidth = (int)(checkCode.Length * 11.5);
            System.Drawing.Bitmap image = new System.Drawing.Bitmap(iwidth, 20);
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
            System.Drawing.Font f = new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold);
            System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.White);
            //g.FillRectangle(new System.Drawing.SolidBrush(Color.ed),0,0,image.Width, image.Height);
            g.Clear(System.Drawing.Color.Red);
            g.DrawString(checkCode, f, b, 3, 3);        //System.Drawing.Pen blackPen = new System.Drawing.Pen(System.Drawing.Color.Black, 0);
            Random rand = new Random();
            for (int i = 0; i < 5; i++)
            {
                int y = rand.Next(image.Height);
                //g.DrawLine(blackPen, 0, y, image.Width, y);
            }        System.IO.MemoryStream ms = new System.IO.MemoryStream();
            image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            Response.ClearContent();
            Response.ContentType = "image/Jpeg";
            Response.BinaryWrite(ms.ToArray());
            g.Dispose();
            image.Dispose();
        }<asp:Image Runat="server" ID="ImageCheck" ImageUrl="confirm.aspx"></asp:Image>
      

  6.   

    你那段代码 是执行在ASP页面  当然可以执行的 但是SESSION共享 好不好用 就不确定了你取值 试试  一定要考虑编码问题