ASP.net implementation Verification Code technology (online collection)
Source: Internet
Author: User
The first step is to generate the verification code
Add a validatecode.aspx page
The code in ValidateCode.aspx.cs is as follows
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 System.Drawing;
Using System.Drawing.Imaging;
public partial class ValidateCode:System.Web.UI.Page
{//This page will be used to generate the CAPTCHA picture
protected void Page_Load (object sender, EventArgs e)
{//Calling function to generate a picture of a captcha
This. Createcheckcodeimage (Generatecheckcode ());
}
private String Generatecheckcode ()
{//Generate five-bit random string
int number;
char code;
string checkcode = String.Empty;
System.Random Random = new Random ();
for (int i = 0; i < 5; i++)
{
Number = random. Next ();
if (number% 2 = 0)
Code = (char) (' 0 ' + (char) (number% 10));
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service