C#代码如下:
<%@ WebHandler Language="C#" Class="防盗链" %>
using System;
using System.Web;
public class 防盗链 : 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("禁止提交图片", new System.Drawing.Font("宋体", 30), System.Drawing.Brushes.RosyBrown, 0, 0);
}
else if(context .Requ