简体   繁体   English

如何检测浏览器或下载管理器是否正在下载文件

[英]How do you detect if a file is being downloaded by a Browser or a Download Manager

I am curious as to how the file sharing sites like rapidshare detect users downloading files through download managers. 我对诸如Rapidshare这样的文件共享站点如何检测通过下载管理器下载文件的用户感到好奇。

How do you enable an ASP.NET web application to prevent downloads from a download manager. 如何启用ASP.NET Web应用程序以防止从下载管理器进行下载。

When you are a server, you can receive some interesting info about the client that access you. 当您是服务器时,您会收到一些有关访问您的客户端的有趣信息。

One of the parameters is telling you the "User Agent", or in simple words the browser type. 参数之一是告诉您“用户代理”,或者简单地说就是浏览器类型。

In PHP it's in the array $_SERVER ( http://php.net/manual/en/reserved.variables.server.php ). 在PHP中,它位于数组$ _SERVER( http://php.net/manual/en/reserved.variables.server.php )中。

In Dot Net, I think it's part of the HttpRequest class ( http://msdn.microsoft.com/en-us/library/system.web.httprequest.aspx ). 在Dot Net中,我认为它是HttpRequest类的一部分( http://msdn.microsoft.com/zh-cn/library/system.web.httprequest.aspx )。

On real-time, you can "ask" those params what are the client type (IE, Firefox, or an independent client), and react to it like preventing download. 实时地,您可以向那些参数“询问”客户端类型(IE,Firefox或独立客户端)的类型,并对它做出反应,例如阻止下载。

Sites like rapidshare don't have any access to your browsers/download managers. Rapidshare之类的网站无法访问您的浏览器/下载管理器。 They find out the info about your downloads from their server according to your IP address. 他们根据您的IP地址从服务器中找到有关您下载内容的信息。

I don't think you can make any web-application which can have such permissions. 我认为您无法制作任何具有此类权限的Web应用程序。

What do you want to prevent? 您想预防什么? A download-manager isn't evil by itself. 一个下载管理器本身并不是邪恶的。

How do you even define a download manager? 您甚至如何定义下载管理器? Every web-browser has an integrated download-manager of varying quality. 每个网络浏览器都有一个集成的质量不同的下载管理器。

You should try to prevent the behavior you don't like in download-managers, and not download-managers themselves. 您应该尝试防止在下载管理器中出现不喜欢的行为,而不是在下载管理器本身中。

  • You can prevent automated downloads using captchas(but might not always work and annoys users) 您可以使用验证码阻止自动下载(但可能并不总是有效,并且会惹恼用户)
  • And you can prevent multiple downloads in parallel by allowing only one download per IP. 通过每个IP仅允许一次下载,您可以防止并行进行多次下载。

我相信引荐来源网址( http://en.wikipedia.org/wiki/HTTP_referrer )可以用作另一个廉价的检查,以查看在何处启动下载。

Most of the download managers also use the Accept-Header HTTP header allowing partial content download and restart over resets. 大多数下载管理器还使用Accept-Header HTTP标头,允许部分内容下载并通过重置重新启动。 See some docs here: HTTP Status: 206 Partial Content and Range Requests 在此处查看一些文档: HTTP状态:206部分内容和范围请求

if you mean preventing resumable and multi-connection downloads you should add a Accept-Ranges:none header to your response . 如果您要阻止可恢复的下载和多连接下载,则应在response中添加一个Accept-Ranges:none标头。

In Asp.net or Asp.net MVC: 在Asp.net或Asp.net MVC中:

Response.AddHeader("Accept-Ranges", "none");

To know more about this see Accept-Ranges 要了解更多信息,请参见接受范围

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Ajax方法下载excel文件-我的文件是在Temp文件夹中下载的,而不是在Browser中下载的? - How to download excel file using Ajax method- here my file is downloaded in Temp folder not Downloaded in Browser? 为什么此操作不会导致下载文件? 怎么做? - Why this action doesn't result in a file being downloaded? How to do that? 如何强制浏览器下载xml文件? - How can you force the browser to download an xml file? Asp.Net Core:如何使浏览器显示文件在发送之前被下载 - Asp.Net Core: how to make the browser show file as being downloaded before it's sent 如何检测从BHO下载的文件类型? - How Do I Detect A File Type Download From A BHO? 如何使用C#在asp.net中下载文件后取消文件下载的输入键事件 - how to cancel enter key event for file download after file is being downloaded in asp.net using C# 如何检测用户何时开始在浏览器中下载? - How to detect when user start download in browser? 如何在 .NET 中直接触发下载的 S3 文件的下载窗口? - How do I directly trigger a download window for a downloaded S3 file in .NET? 如何检测文件下载请求 - How to detect file download request 如何验证是否在Selenium Webdriver C#中下载文件 - How do I verify if a file is being downloaded in Selenium Webdriver C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM