C#实现的访盗链的FileHandler
2018-07-20 来源:open-open
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;
}
}
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:C#查找字符串的所有排列组合
下一篇:C# 操作windows注册表
最新资讯
热门推荐