日期:2014-05-17 浏览次数:20498 次
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();
}
}
}
<httpHandlers>
<add verb="*" path="*.jpg" type="Protect,Haiyang"/>
</httpHandlers>