<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<!--网站防盗链-->
<img src="images/47578.jpg" />
</div>
</form>
</body>
</html>
------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
/// <summary>
///otherLink 的摘要说明
/// </summary>
public class otherLink:IHttpHandler
{
private const string ERRFILE = "~/images/pagerror.gif";
public otherLink()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
#region IHttpHandler 成员
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
//约定localhost:11222
if (context.Request.UrlReferrer.Host == "localhost" &&
context.Request.UrlReferrer.Port == 11222 )
{
context.Response.Expires = 0;
context.Response.Clear();
FileInfo file = new FileInfo(context.Request.PhysicalPath);
context.Response.AddHeader("Content_Disposition", "filename=" + file.Name);
context.Response.AddHeader("Content_Length", file.Length.ToString());
string fileExtension = file.Extension.ToLower();
switch (fileExtension)
{
case "jpg":
context.Response.ContentType = "image/jpeg";
break;
//......
}
context.Response.WriteFile(context.Request.PhysicalPath);
context.Response.End();
}
else
{
context.Response.WriteFile(context.Request.MapPath(ERRFILE));
context.Response.ContentType = "text/plain";////?
context.Response.Write("<a href='http://localhost:11222/Default.aspx'>跳转到原始网站!</a>");
context.Response.End();
}
}
#endregion
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
/// <summary>
///otherLink 的摘要说明
/// </summary>
public class otherLink:IHttpHandler
{
private const string ERRFILE = "~/images/pagerror.gif";
public otherLink()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
#region IHttpHandler 成员
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
//约定localhost:11222
if (context.Request.UrlReferrer.Host == "localhost" &&
context.Request.UrlReferrer.Port == 11222 )
{
context.Response.Expires = 0;
context.Response.Clear();
FileInfo file = new FileInfo(context.Request.PhysicalPath);
context.Response.AddHeader("Content_Disposition", "filename=" + file.Name);
context.Response.AddHeader("Content_Length", file.Length.ToString());
string fileExtension = file.Extension.ToLower();
switch (fileExtension)
{
case "jpg":
context.Response.ContentType = "image/jpeg";
break;
//......
}
context.Response.WriteFile(context.Request.PhysicalPath);
context.Response.End();
}
else
{
context.Response.WriteFile(context.Request.MapPath(ERRFILE));
context.Response.ContentType = "text/plain";////?
context.Response.Write("<a href='http://localhost:11222/Default.aspx'>跳转到原始网站!</a>");
context.Response.End();
}
}
#endregion
}
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
分享到:
相关推荐
附件防盗链-管理插件 V3.0Attachment_pjblog.rar
2014年我在某公司作的 OTT 项目中, 机顶盒防盗链文案
利用httpHandler 实现RSS 图片防盗链接 图片验证码等功能
可以破解任何网站的图片防盗链,极简的代码,使用时只需将图片地址改成http://你的网址/i.asp?url=图片原地址,即可调用任何网站的图片。
我来教你玩转iis防盗链 MYIIS-VIF超级防盗链.docx
主要介绍了 java 防盗链详解及解决办法的相关资料,这里介绍了防盗链的概念、产生原因及Http中的referer,最后介绍解决办法,需要的朋友可以参考下
网站防盗链: IIS7.5配置防盗链 IIS7.0配置防盗链
基于页面访问ip授权可以说是目前最有效的防盗链机制。 本程序的ip授权列表结构采用专用算法,十分高效,不会对IIS性能造成太大影响。 注意:如果IIS服务重新启动,授权ip列表将自动清空,用户下载需要重新访问页面...
关于IPv6很详尽的描述,介绍了各种基本知识,包括1Pv6 编址、ICMPv6 与邻居发现协议、1Pv6 路由、DHCPv6 等内容,并详细讨论了包括双枝、 隧道、转换在内的各种1Pv4 向1Pv6 迁移的过渡技术。
这里的代码是用来保护你的网站上传的文件的,它可以在用户知道完整的文件URL的时候,也无法下载你的文件。这样就可以保护你的资源免于被别的网站盗链的问题。
HttpURLConnection+jsoup防盗链 {"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661...
RealServer防盗链插件(UUReal防盗链)
java防盗链代码,和jar 配置文件等, demo
Asp.net防盗链实例源码 通过设置web.config中的域名即可控制哪些域名是允许的,设置是否直接下载、是否允许盗链 <!--是否直接下载--> <!--是否允许盗链--> <!--多个允许的访问来源用半角的","分割--> ...
iis 防盗链 音乐网站防盗链 图片防盗链
文件防盗链示例源码 主要功能: 对一些敏感文件设置防盗链 防止url直接下载 该文件提供两种防盗链方式 一种通过配置文件(仅在IIS测试并通过) 另一种通过aspnet的拦截机制 对访问文件后缀名进行拦截 两种方式均已...
IIS防盗链(超简单版)附带防盗链效果for phpwind
相信很多人,不管是私人也好,seo也好,站长也好,还是小推手也好,都会不时越到“防盗链图片”这个问题,有时候需要把整个网页文章拷贝进去,但是复制过去的图片,到自己的网站这边,刷新一下就没了~~~给自己活着给...
防盗链完美解决方案 防盗链完美解决方案,提供给你一些安全的方法。
一个简单的代码演示如何绕过网站设置的防盗链技术