Joke Collection Website - Blessing messages - How to implement verification code in ASP.NET?
How to implement verification code in ASP.NET?
1. Introduction to knowledge points: Verification codes are actually randomly generated numbers. The Random class provided under the System namespace can be used to generate random non-negative numbers. In System in ASP.NET. In the Drawing namespace, Bitmap and Graphics classes are provided. The Bitmap class encapsulates the GDI+ bitmap, inherits from the Image class, and is used to process images defined by pixel data. The Graphics class encapsulates GDI and the drawing surface, which is equivalent to Drawing board. Next, use the Random, Bitmap and Graphics classes to draw the generated random numbers into the created bitmap. And use the Image control to display the created bitmap. 2. Example: Create a new "WebForm1.aspx" page and add a Image control, and set its ImageUrl property to the path where the generated bitmap will be stored. (1) WebForm1.aspx.cs code: private void Page_Load(object sender, System.EventArgs e){//Create a bitmap object Bitmap newBitmap= new Bitmap(36,16,System.Drawing.Imaging.PixelFormat.Format32bppArgb);//Create a drawing layer based on the bitmap object created above Graphics g=Graphics.FromImage(newBitmap);//Fill the rectangular area with the specified color g.FillRectangle(new SolidBrush(Color.White),new Rectangle(0,0,36,16));//Create the font object Font textFont=new Font("Times new Roman",10);//Create the RectangleF structure Specify an area RectangleF rectangle=new RectangleF(0,0,36,16);//Create a random number object Random rd=new Random();
- Related articles
- Happy New Year greetings 224
- How many people in Xuebajun have successfully refunded their money?
- How many text messages can I send for Unicom Card 128 package?
- Does marriage registration in Liaoyang need nucleic acid testing?
- On November 16, two people who were initially positive were found in the close contact screening in Hecheng District, Huaihua
- Why did Samsung receive text messages twice?
- Solve the problem of insufficient memory in Apple.
- Does the eye-catching Xia Na look good? A brief comment on this animation must be based on your real feelings and say whatever comes to mind.
- 2020 Olympic Games (global unity, collective creation of brilliance)
- Here comes the message. It's gone.