我这里用的图片被盗举例子 一个正常的网页 模拟一个盗用网站的网页 没有任何防盗的操作效果图, 建一个类 找到配置文件添加代码 效果图<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StolenDemo.aspx.cs" Inherits="Stolen.StolenDemo" %> <!DOCTYPE html> <html xmlns="https://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <img src="Images/adv1.jpg" /><img src="Images/adv2.jpg" /><img src="Images/adv3.jpg" /> </div> </form> </body> </html>
localhost是我另一个项目的,这里服务器不方便弄,就直接新建项目<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StealDemo.aspx.cs" Inherits="steal.StealDemo" %> <!DOCTYPE html> <html xmlns="https://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <img src="https://localhost:44353/Images/adv1.jpg" /> <img src="https://localhost:44353/Images/adv2.jpg" /> <img src="https://localhost:44353/Images/adv3.jpg" /> </div> </form> </body> </html>
防盗措施:using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Stolen { public class prevention : IHttpHandler { public bool IsReusable =>true; public void ProcessRequest(HttpContext context) { //上一次的uri与这一次的Uri看看是不是host和port是不是相同,如果不相同说明是被盗了 Uri pre = context.Request.UrlReferrer; Uri cur = context.Request.Url; if (pre.Host != cur.Host || pre.Port != cur.Port) { string errorPath=context.Request.PhysicalApplicationPath+ "Error/default.jpg"; context.Response.WriteFile(errorPath); } else { context.Response.WriteFile(context.Request.PhysicalPath); } } } }
path是防盗的范围,type是那个类的路径:也就是命名空间 .(点)类名
<system.webServer> <handlers> <add verb="*" name="preventLink" path="Images/*.jpg" type="Stolen.prevention"/> </handlers> </system.webServer>
找不到的那个图片,图片无法显示的那个,是一张图片,我在类里面改的,如果是盗取的话,就给他一个找不到的图片
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算