C#实现的访盗链的FileHandler

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

C#实现的访盗链的FileHandler

/// <summary>
/// 访盗链的FileHandler
/// </summary>
public class FileHandler:IHttpHandler
{
public FileHandler()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
 
  public void ProcessRequest(HttpContext context)
  {
  if ((context.Request.UrlReferrer == null) || (context.Request.UrlReferrer.Host == "localhost" && context.Request.UrlReferrer.Port == 16490))
  {
  context.Response.Expires = 0;
  context.Response.Clear();
  context.Response.ContentType = "rar";
  context.Response.WriteFile(context.Request.PhysicalPath);
  context.Response.End();
  }
  else //如果不是本地引用,则属于盗链引用,
  {
 
  HttpResponse response = context.Response;
  response.Redirect(context.Request.ApplicationPath + "/ErrorPage.htm");
  }
 
  }
  public bool IsReusable
  {
  get
  {
  return false;
  }
  }
}