When we log on to a website or handle a comment, we can place a verification code (Captcha) to avoid malicious refresh and other functions for the system.
This time, Insus. NET has implemented and demonstrated the generation and application of verification codes in the asp.net mvc application.
The day before yesterday, Insus. NET has implemented the random generation of a string named "random acquisition of a string in ASP. net mvc application.
Under the Handlers directory of the application, create a Generic Handler named Captcha. ashx, which implements the IRequiresSessionState interface.
In the Controller, create two actions. The former is the view method CaptchaDemo (), and the latter is the jQuery verification method. It has a parameter. The text box of the verification code is passed in. In the method, it is correct to compare it with the string randomly generated in aspx and stored in the Session.
Reference view code:
Demo: