Asp.net| Verification Code
Using System;
Using System.Data;
Using System.Configuration;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
Using System.Drawing;
Using System.Drawing.Imaging;
Using System.Drawing.Text;
public class RandPic:System.Web.UI.Page
{
<summary>
Verification code number
</summary>
public int Num = 0;
<summary>
Picture width
</summary>
public int imgwidth=60;
<summary>
Picture height
</summary>
public int imgheight=30;
Public Randpic ()
{
}
<summary>
Constructors
</summary>
<param name= "Rndnum" > Authentication code number </param>
Public randpic (int rndnum)
{
if (Rndnum > 0)
{
Num = Rndnum;
}
}
<summary>
Generate pictures
</summary>
public void Make ()
{
Bitmap map=new Bitmap (imgwidth,imgheight);
Graphics GP = graphics.fromimage (map);
Gp. Clear (Color.White);
Font ft = new Font ("Arial black", 13);
PointF Point =new PointF (3,3);
Gp. DrawString (Num.tostring (), FT, Brushes.burlywood, point);
Gp. Save ();
Map. Save (Response.outputstream, imageformat.gif);
}
}
Call Page showrand.aspx
Using System;
Using System.Data;
Using System.Configuration;
Using System.Collections;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
Using _14base;
public partial class Manager_logrnd:randpic
{
protected void Page_Load (object sender, EventArgs e)
{
This. Num = 8888;
HttpCookie cookie = new HttpCookie ("Userrnd", Rnd. ToString ());
RESPONSE.COOKIES.ADD (cookie);
This. Make ();
}
}