如何设置验证码, 怎么让他随机出验证码,
步骤呢,
如何设置验证码, 怎么让他随机出验证码,
步骤呢,
是网站编程吗?
你最好找一个现成的验证码控件,装上就用。
GDI+
哥给你写一个吧
//Code.aspx加载事件里面
protected void Page_Load(object sender, EventArgs e) {
//a.jpg是一张图片做验证码背景 string imgPath = Server.MapPath("a.jpg"); System.Drawing.Image img = System.Drawing.Image.FromFile(imgPath); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img);
//随机就不多说了
//把字符串存到session Session["CODE"] = "ABCD"; g.DrawString("ABCD", new System.Drawing.Font("宋休", 15), System.Drawing.Brushes.Blue, new System.Drawing.PointF(0, 0)); System.IO.MemoryStream ms = new System.IO.MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] bts = ms.ToArray(); Response.BinaryWrite(bts); }
//使用的时候
<img src="Default.aspx" />
winfrom的太简单了,应该不是问winfrom的吧