Using System;
Using System. Collections;
Using System. Configuration;
Using System. Data;
Using System. Linq;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. HtmlControls;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Xml. Linq;
Using System. Drawing;
Namespace SessionCode
{
Public partial class checkimage: System. Web. UI. Page
{
/// <Summary>
/// Verification Code Generation Program
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void Page_Load (object sender, EventArgs e)
{
GetCode ();
}
// Generate code
Protected void GetCode ()
{
System. Random rand = new Random ();
Int len = 4; // set the verification code length here. I defined it as 4. Recently, I have seen random numbers of 4, 5, and 6 characters on the Internet. Write a random function here.
Char [] chars = "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ". ToCharArray ();
System. Text. StringBuilder myStr = new System. Text. StringBuilder ();
For (int iCount = 0; iCount <len; iCount ++)
{
MyStr. Append (chars [rand. Next (chars. Length)]);
}
String text = myStr. ToString ();
// Save the verification code to the session for other modules to use
Session ["code"] = text; // check whether the entered verification code is correct on your login page. if (txtCode. text = Session ["code"]) read the database correctly and retrieve the User/Password. An incorrect dialog box is displayed. Write by yourself
Size ImageSiz