zoukankan      html  css  js  c++  java
  • 引用 Asp.net下实现隐藏真实下载地址(可以实现简单的防盗链)(转载)

    引用

    e路共赢Asp.net下实现隐藏真实下载地址(可以实现简单的防盗链)
    现 在随着FlashGet和xunlei等下载工具的日益普及,下载网站的一些下载地址都能直接被捕获到,,但是有些时候为了防盗链或权限限制不想对地址进 行暴露,对于Asp.net下的防盗链有很多方法,我这里写了一种(51aspx的新版本将会采纳)希望大家讨论一下:
                string filename = "Test.rar";

                
    if (filename != "")
                
    {
                    
    string path = Server.MapPath(filename);
                    System.IO.FileInfo file 
    = new System.IO.FileInfo(path);
                    
    if (file.Exists)
                    
    {
                        Response.Clear();
                        Response.AddHeader(
    "Content-Disposition""attachment; filename=" + file.Name);
                        Response.AddHeader(
    "Content-Length", file.Length.ToString());
                        Response.ContentType 
    = "application/octet-stream";
                        Response.WriteFile(file.FullName);
                        Response.End();
                    }

                    
    else
                    
    {
                        Response.Write(
    "该文件不存在!");
                    }

                }


    当然这样也有弊端,就是用户只能用IE单线程进行下载,对于分量小的下载地址来说这个无所谓了,如果各位还有其他更好的办法,欢迎补充~~ -----------------
  • 相关阅读:
    js 把数组中每个元素的某个字段取出
    vue 实现单选/多选效果
    js常用的array方法
    js的split()和join()的用法
    HTML 转 PDF 之 wkhtmltopdf
    微信小程序api封装(promise)
    常用的正则表达式
    更改MySQL的存储目录
    CentOS 6.X 安装VirtualBox-5.1
    CentOS 6.X 安装VNC Server实现图形化访问
  • 原文地址:https://www.cnblogs.com/chenying99/p/1983133.html
Copyright © 2011-2022 走看看