ASP.net verification code technology (online collection)

Source: Internet
Author: User


Step 1: generate a 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 a verification code Image
Protected void Page_Load (object sender, EventArgs e)
{// Call the function to generate an image of the Verification Code
This. CreateCheckCodeImage (GenerateCheckCode ());

}
Private string GenerateCheckCode ()
{// Generate a five-digit 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 ));

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.