生成随机验证码

&lt;%@ Page Language="C#" Buffer="false" %&gt;<br>&lt;%@ OutputCache Location="None" %&gt;<br>&lt;%@ Import Namespace="System.Drawing" %&gt;<br>&lt;%@ Import Namespace="Dinge.WapAD.Common.Validate" %&gt;<br>&lt;script language="C#" runat="server"&gt;<br><br>private void Page_Load(object sender, System.EventArgs e)<br>{<br> //if (Request.UrlReferrer == null || Request.UrlReferrer.Host != "localhost") return;<br><br> VerifyCode v = new VerifyCode();<br><br> v.Length = !IsType.isInt32(Request.QueryString.Get("l")) ? 5 : Convert.ToInt32(Request.QueryString.Get("l"));<br><br> v.FontSize = !IsType.isInt32(Request.QueryString.Get("f")) ? 10 : Convert.ToInt32(Request.QueryString.Get("f"));<br><br> v.Padding = !IsType.isInt32(Request.QueryString.Get("p")) ? 4 : Convert.ToInt32(Request.QueryString.Get("p"));<br><br> v.BackgroundColor = Color.White;<br><br> v.PadColor = Color.SlateGray;<br><br> v.Chaos = true;// 噪点<br><br> v.ChaosColor = Color.GreenYellow;<br><br> v.ChaosNum = 68;<br><br> v.Fonts = new String[] { "Georgia", "Batang", "Verdana" };// {"Verdana"};<br><br> v.CodeSerial = "0,1,2,3,4,5,6,7,8,9";<br><br> string code = v.CreateVerifyCode();    //取随机码<br><br> v.CreateImageOnPage(code, this.Context);  // 输出图片<br><br> Session["CheckCode"] = code.ToLower();   // 使用Session["CheckCode"]取验证码的值<br>}<br><br>&lt;/script&gt;

你可能感兴趣的:(验证码)