<%@ WebHandler Language=C# Class=防盗链 %>
using Systemusing SystemWeb
public class 防盗链 IHttpHandler {
public void ProcessRequest (HttpContext context) { contextResponseContentType = image/JPEGstring fullpath = HttpContextCurrentServerMapPath(~/image/jpg)using (SystemDrawingBitmap bitmap = new SystemDrawingBitmap(fullpath))
{ using (SystemDrawingGraphics g = SystemDrawingGraphicsFromImage(bitmap))
{ if (contextRequestUrlReferrer == null)
{ gClear(SystemDrawingColorWhite)gDrawString(禁止提交图片 new SystemDrawingFont(宋体 ) SystemDrawingBrushesRosyBrown )} else if(context RequestUserHostAddress !=localhost||context Request UserHostAddress !=)
{ gClear(System Drawing Color White )gDrawString(禁止盗链new SystemDrawingFont (宋体)System Drawing Brushes RosyBrown )}
} bitmapSave(context Response OutputStream System Drawing Imaging ImageFormatGif )}
public bool IsReusable { get { return false}
}