怎么判断验证码是否输入正确?
//CheckCode.aspx.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Configuration;
using System.Web.Security;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class CheckCode : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// 首先调用RndNum函数生成4位数字的验证码
string str_ValidateCode = RndNum(4);
// 然后把它保存在用于验证的Session里边
Session["ValidateCode"] = str_ValidateCode;
//调用CreateImage函数,把验证码绘制到图片中
CreateImage(str_ValidateCode);
}
}
private string RndNum(int VcodeNum)
{
string Vchar = "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,v,w,x,y,z";
string[] VcArray = Vchar.Split(new Char[] { ',' });
string VNum = "";
//int temp = -1;
Random rand = new Random();
for (int i = 1; i < VcodeNum + 1; i++)
{
int t = rand.Next(36);
VNum += VcArray[t];
}
return VNum;
}
//生成随机颜色
private Color GetRandomColor()
{
Random RandomNum_First = new Random((int)DateTime.Now.Ticks);