Recently, I received a task to add a graphic verification code when sending an SMS verification code. Step 1: Find the code to generate the graphic verification code from the Internet, and find several types as follows (adjust the style according to the style of your personal website):
Step 2: Implement the verification function. Option 1: The verification code is stored in the session, but the webapi disables the session by default, and you need to configure it manually; Find the Global.asax file in the interface project and add the following code:
Problem: After depositing the session, when verifying the value, it is found that the session has always been null due to the separation of the front and back ends. Solution: Use CORS to solve WebAPI cross-domain problems;
Option 2: Store the verification code in the cache and select redis; Note: Clear the corresponding cache data in time after verification is completed. The cache time setting is not too long. Achieve results:
Source code download address: WebAPI implements graphical verification code verification .rar Download
Tourists, if you want to see the hidden content of this post, please Reply
|