asp.net MVC Validation Code Demo

Source: Internet
Author: User

When we log on to a website or make a comment, we can place a verification code (CAPTCHA), which can be used for the system to eliminate the malicious refresh functions.

This insus.net is implemented in the ASP.net MVC application and demonstrates the generation and application of verification codes.

The day before yesterday, Insus.net has implemented a randomly generated string "get a random string in a asp.net MVC application http://www.cnblogs.com/insus/p/3619224.html, we can use this method later," Randomly generates a validation string.

In the application's handlers directory, create a generic handler named Captcha.ashx, which has a implemented IRequiresSessionState interface.

In controller, two action is created, the former is the View Method Captchademo () and the latter is the method of validating jquery. It has a parameter with it. The text box text for the validation code will be passed in. Within the method, the string that is randomly generated in ASPX is compared to the session to be correct or not.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/aspx/

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.