Asp. NET complete code tutorial for graphics verification Code

Source: Internet
Author: User
This article introduces the implementation of ASP. NET picture Verification code, the code is easy to understand, very good, with reference value, the need for reference of friends

This article to share a piece of ASP. NET code Implementation graphics Verification code function, the code is easy to understand, the specific code is as follows:

Context.   Response.ContentType = "Image/jpeg"; Generate random Chinese verification code String Yzm = "Population hand size how much upper and lower men and women Heaven anti-Qing Yang Zhengko Small Baodire namespace language now come to me more than one tomorrow Shandong Hebei South Gu ' an Beijing Nanchang Donghassian is Shahe Higher Education Park Science" + "Wood wo up and down soil eight into the great Heaven Fire six or seven son nine no Mouth Sub-door month does not open four or five head meter see white field electric also Chang-fei horse bird cloud bus cow sheep small towel teeth foot hair and heart hand Huang foot "+" walk side half bar industry Motohira book Self things back piece rawly fruit several with fish this is rain two melon clothing next year around hundred Dinzidong said friends Chun Gao you green, grass, the old line of the year of the age of the ancient sound know more busy wash true recognition Father sweep "+ "Mom and Dad write the whole closed home to see a smile xing painting will mother milk put girly too early to light and Li Yuxiu thousand fragrant listen to sing to even more after the master always start dry Ming catch net with special work class team ant anterior chamber Empty network poem Huang Lin closed" + " Dongli is my leaf beauty machine she sent it to him when he gave it to the worm is the river borrow elder sister Ah, who is afraid of the amount with the most garden face because Yang for the Guangkofa find do not let that to all scare to do like a point like the sand sand Bridge Army bamboo seedling well face township "+"   Forget to miss the king this from the edge of the shell of the male love shrimp run music to the old Quick Division short light on the hot cold love pull live to eat practice study non-bitter often ask companion want No child to choose north Hunan Autumn River only help star please snow ball jump play "+" peach just blue seat each belt sit urgent name hair into move late new have to change what article ";   Random r = new Random ();   String validcode = ""; for (int i = 0; i < 4; i++) {int number = R.next (0, Yzm.    Length);   Validcode + = Yzm[number]; }//Paint using (Bitmap B = new Bitmap ()) {using (Graphics g = graphics.fromimage (b)) using (Font F = new F Ont ("Arial")) {g.clear (Color.yellow);//clear the entire drawing face and fill the specified background color g.drawstring (Validcode, F, brushes.red, new PointF (0,  0)///Start drawing//Pre-attraction for (int i = 0; i < i++) {    int x = r.next (0, 150);      int y = r.next (0, 30);     B.setpixel (x, y, color.red);      }//Background line for (int i = 0; i <; i++) {int x = r.next (0, 150);      int y = r.next (0, 30);     G.drawline (pens.red, x, y, x + 1, y + 1); }} b.save (context. Response.outputstream, imageformat.jpeg);//save to output stream}

Reference:

A collection of methods for generating verification codes for ASP (i)

An implementation method of WebForm image watermark and image Verification code for ASP.

"Recommended"

1. Special recommendation : "PHP Programmer Toolkit" V0.1 version download

2. asp free Video Tutorial

3. ASP Reference Manual

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.