如题,如果已经在网站上设置了反盗链的处理,然后,我在本地测试,还是可以用站的图片,比如  在VS中<asp:Image ID="Image1" runat="server" ImageUrl="http://www.XXYY.com/image/logo.jpg" />,不会弹出一个提示盗链的消息

解决方案 »

  1.   

    public void ProcessRequest(HttpContext context)
        {
                  if (context.Request.UrlReferrer.Host == "localhost")
            {
                           context.Response.Expires = 0;
                            context.Response.Clear();
                            context.Response.ContentType = "image/jpg";
                           context.Response.WriteFile(context.Request.PhysicalPath);
                          context.Response.End();
            }               else
            {
                           context.Response.Expires = 0;
                           context.Response.Clear();
                           context.Response.ContentType = "image/jpg";
                           context.Response.WriteFile(context.Request.PhysicalApplicationPath + "images/error.jpg");
             context.Response.End();        }
      

  2.   

    改成UrlReferrer.AbsolutePath.StartsWith("localhost")呢?我忘了。
      

  3.   

    唉,要我说,除非你们家BOSS强烈要求,否则,盗链对你来说,只有好处哪里有坏处。
    个人建议,不要舍本逐末了。