日期:2014-05-17  浏览次数:20454 次

ASP.NET关于防止盗链代码,求指点
本帖最后由 u011335204 于 2013-08-03 10:56:27 编辑
以下是一段模仿在网上看到的防盗链的代码

原文地址:http://www.jb51.net/article/26174.htm

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 = "image/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();
        }
    } 
}

我的Web.config
<httpHandlers>
      <add verb="*" path="*.jpg" type="Protect,Haiyang"/>
    </httpHandlers>

运行时报错,说是web.config有问题
在处理向该请求提供服务所需的配置文件时出错。请检查下面的特定错误详细信息并适当地修改配置文件。 

分析器错误消息: 未能加载文件或程序集“Haiyang”或它的某一个依赖项。系统找不到指定的文件。

但我不知道要怎么改?什么空间什么的也不知道是什么