打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
网站空间图片防盗链代码
转载的不知道是否能用,等用到时再试
ASP.NET中图片防盗链。ASP.NET中添加一个img.ashx文件,然后后台代码如下:


using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
namespace GetImage
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = " http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Img : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/jpg";
if (context.Request.UrlReferrer != null && context.Request.UrlReferrer.Host.Equals(context.Request.Url.Host, StringComparison.InvariantCultureIgnoreCase))
context.Response.WriteFile(context.Server.MapPath("~/" + context.Request.QueryString["img"]));
else
context.Response.WriteFile(context.Server.MapPath("~/logo.gif"));
}
public bool IsReusable
{
get
{
return false;
}
}
}
}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
ASP.NET2.0 遍历文件夹下所有图片..
图像防盗链突破,教你制作自己的图片突破URL
在ASP.Net(C#)中调用服务器端的控制台应用程序
图片与字节数组相互转换的方法
c#调用系统资源
如何在 "万一的 Delphi 博客" 回复自动格式化的着色代码?
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服