biu.me

Tag Archives: 盗链

很久以前写的解决163相册不允许盗链的代码

public void GetFile(string strFileURL) { string strPhotoRef = strFileURL.Substring(0, strFileURL.IndexOf("/", 8) + 1); //Like: http://img123.photo.163.com/ XMLHTTP _xmlhttp = new XMLHTTPClass(); _xmlhttp.open("GET", strFileURL, false, null, null); _xmlhttp.setRequestHeader("Connection", "Keep-Alive"); _xmlhttp.setRequestHeader("Referer", strPhotoRef); _xmlhttp.send(String.Empty); if(_xmlhttp.readyState == 4) { //Response.ContentType = "image/*"; Response.BinaryWrite((Byte[])_xmlhttp.responseBody); Response.End(); //Response.Redirect(strFileURL); } else { Response.Write("Error!"); } } 现在这样非常消耗服务器资源,如果再加上缓存的思路性能会提升不少。