using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;/// <summary>
///Protect 的摘要说明
/// </summary>
public class Protect:IHttpHandler
{
public Protect()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
    public bool IsReusable
    {
        get { return true; }
    }
    public void ProcessRequest(HttpContext context)
    {
        if (null != context.Request.UrlReferrer)
        {
            context.Response.Expires = 0;
            context.Response.Clear();
            context.Response.ContentType = "images/jpg";
            context.Response.WriteFile(context.Request.PhysicalPath);
            context.Response.End();
        }
        else
        {
            context.Response.Expires = 0;
            context.Response.Clear();
            context.Response.ContentType = "text/html";
            context.Response.Write("混蛋!你在非法盗链");
            context.Response.End();
        }
    } 
}
以上是一段防止jpg图片盗链的代码,但是只能防jpg图片我想做防所有图片还有FLASH(视频),比如说jpg,png,swf
webconfig:
<httpHandlers>
      <add verb="*" path="*.jpg" type="Protect,App_code"/>
      <add verb="*" path="*.png" type="ProtectPng,App_code"/>
    </httpHandlers>
ASP.NET