1 call
2. Generate the handler1.ashx of the image.
Public class handler1: ihttphandler, irequiressessionstate
{
Public void processrequest (httpcontext context)
{
Context. response. contenttype = "image/JPEG ";
Using (Bitmap BP = new Bitmap (100, 50 ))
{
Using (Graphics G = graphics. fromimage (BP ))
{
Random r = new random ();
Int code = R. Next (1000,999 9 );
String strcode = code. tostring ();
Httpcontext. Current. session ["code"] = strcode;
G. drawstring (strcode, new system. Drawing. Font ("", 12), brushes. Green, new system. Drawing. pointf (0, 0 ));
BP. Save (context. response. outputstream, system. Drawing. imaging. imageformat. JPEG );
}
}
}
Note: A. irequiressessionstate must implement this interface. To call httpcontext. Current. session ["code"] = strcode
B. AA = '+ new date () "for stand-alone images, You can refresh the verification code Image
Verification Code Test