C # The Code is as follows:
<% @ WebHandler Language = "C #" Class = "anti-Leech" %>
Using System;
Using System. Web;
Public class anti-leech: IHttpHandler {
Public void ProcessRequest (HttpContext context ){
Context. Response. ContentType = "image/JPEG ";
String fullpath = HttpContext. Current. Server. MapPath ("~ /Image/22.jpg ");
Using (System. Drawing. Bitmap bitmap = new System. Drawing. Bitmap (fullpath ))
{
Using (System. Drawing. Graphics g = System. Drawing. Graphics. FromImage (bitmap ))
{
If (context. Request. UrlReferrer = null)
{
G. Clear (System. Drawing. Color. White );
G. DrawString ("do not submit images", new System. Drawing. Font ("", 30), System. Drawing. Brushes. RosyBrown, 0, 0 );
}
Else if (context. Request. UserHostAddress! = "Localhost" | context. Request. UserHostAddress! = "127.0.0.1 ")
{
G. Clear (System. Drawing. Color. White );
G. DrawString ("leeching prohibited", new System. Drawing. Font ("", 30), System. Drawing. Brushes. RosyBrown, 0, 0 );
}
}
Bitmap. Save (context. Response. OutputStream, System. Drawing. Imaging. ImageFormat. Gif );
}
}
Public bool IsReusable {
Get {
Return false;
}
}
}
From programmers