In order to prevent malicious users, or use the software to submit some content, you have to use a verification code to block, although this will affect the user experience, but in order to avoid some problems many sites have used a verification
Detailed description of how to generate a verification code-ASP. NET details (4) and asp.net detailsPreface
Today, I want to explain in detail all the issues with the verification code generated during ASP. NET Website development.
The goal of this
// The following code is placed on the JSP server to generate a Random Digital Image verification code.
Color getrandcolor (int fc, int BC){Random random = new random ();If (FC> 255) fc = 255;If (BC> 255) BC = 255;Int r = FC + random. nextint (BC-Fc
1. Ideas:The verification code image on the page is servlet, and jquery is used for asynchronous verification of information.
2. Files usedVerifycodeservlet. Java -- Servlet used to generate images
Resultservlet. Java -- used to verify the
Image. jsp
Color getrandcolor (int fc, int BC ){Random random = new random ();If (FC> 255) fc = 255;If (BC> 255) BC = 255;Int r = FC + random. nextint (BC-Fc );Int G = FC + random. nextint (BC-Fc );Int B = FC + random. nextint (BC-Fc );Return new
Validatecode. ashx
using system; using system. data; using system. web; using system. collections; using system. web. services; using system. web. services. protocols; using system. drawing;
Public class validatecode: ihttphandler {
Public
Disable the user from being locked. Set membership. maxinvalidpasswordattempts = the maximum number of logins
How to obtain the textbox value in the login control:Textbox txtimage = login2.findcontrol ("txtvalidator") as textbox;If (txtimage.
ASP. NET Verification Code (3 types)
1. gsc_webcontrollibrary this is a control found on the Internet and is very useful. But the effect is not very good (see.
) Although it is easy to use, all attributes can be set like controls, but the
JDK started to have enumeration types, while the cute Java organization enriched the switch statement: enumeration is supported.
Define an enumeration class color
public enum Color {RED("red color", 0), GREEN("green color", 1),BLUE("blue color", 2)
Tomcat webapps to create a directory validate, build a WEB-INF Directory, which creates a web. xml file, the Code does not need to be written, there is a statement on the line: Web. xml:
Xmlns = "http://java.sun.com/xml/ns/j2ee"
Xmlns: xsi = "http:/
1. getoutputstream () appears in JSP of tomcat5 () cause and solution of has already been called for this response exception: this error occurs in JSP under Tomcat 5. The output stream is usually used in JSP (for example, the output image
Image verification codes are common on the Web login interface. The following is a simple example written in C.
1. CreateValidateImage. aspxPage, pay attention to reference the two namespaces System. Drawing and System. Drawing. Imaging.The Code is
First, draw a verification code. This is very simple.
Paste the code
ImageValidate. aspx
Protected void Page_Load (object sender, EventArgs e){// Generate a four-digit Verification CodeCreateCheckCodeImage (GenerateCheckCode ());}Private string
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.