Using System;
Using System. Web;
Using System. Drawing;
/// <Summary>
/// Summary of Png.
Public sealed class LocalPng: IHttpHandler
{
# Region IHttpHandler Member
Public void ProcessRequest (HttpContext context)
{
If (context. Request ["key"]! = Null & context. Request ["key"]. Length = 4) // there are numbers with an ACSSI Code of 1-9 and letters with a-z
{
String machine_key = context. Request ["key"];
Context. Response. Clear ();
Try
{// Source Image
Bitmap sImage = new Bitmap (context. Server. MapPath ("key.png.bmp"); // image path
// Verification Code Diagram
Graphics wg = Graphics. FromImage (sImage );
Wg. DrawString (machine_key, new Font ("Comic Sans MS", 14), new SolidBrush (Color. RoyalBlue), 3, 0 );
Wg. Save ();
Context. Response. ContentType = "image/Jpeg ";
SImage. Save (context. Response. OutputStream, System. Drawing. Imaging. ImageFormat. Jpeg );
Wg. Dispose ();
SImage. Dispose ();
}
Catch (Exception e)
{Context. Response. Write (e. Message );
}
Context. Response. End ();
}
}
Public bool IsReusable
{
Get
{
// TODO: Add CodeKey. IsReusable getter implementation
Return false;
}
}
# Endregion
}