ASP. net mvc Verification Code demonstration (Ver2)

Source: Internet
Author: User

In the previous version of ASP. net mvc Verification Code demonstration, http://www.cnblogs.com/insus/p/3622116.html. insus.netalso uses generic handler to generate a verification code image, which has been used by Insus. NET in asp.net development.

In this article, Insus. NET does not use ASHX. There are many methods in MVC development.


You can create a custom Result named CaptchaResult. cs to inherit the ContentResult class.

 

In the controller, write three actions: ActionResultCaptchaDemo_Ver2(), CaptchaResultGetCapptImage() And JsonResultCaptchaValid(String captchaText ).

 

The following is the implementation View:

 

Mark 1: write html markup. There is a file box for users to enter the characters of the Verification Code, there are img displaying the verification code, the verification button, and the display information label.

Mark 2 to reference the jQuery library.

Mark 3. When the view is loaded for the first time, the dynamically generated verification code is displayed.

Mark 4. Click the verification code image to change it instantly.

Mark 5 to verify that the verification code entered by the user is correct.

Mark 6 to pass in the verification code entered by the user.

Mark 7 and return the verification result.


Test Run page to see whether the correct verification code is entered, all get "Not Found ".

 

The attribute of the original Action is different from the request method used by jQuery. One is POST and the other is HttpPost. The correct method is POST> HttpPost;

 

Change to consistency to solve the problem. Demonstration:

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.