ASP.NET 图片加水印防盗链
来源:互联网 发布:淘宝描述相符怎么提高 编辑:程序博客网 时间:2024/06/10 20:11
首先建一个类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;
/// <summary>
///Class1 的摘要说明
/// </summary>
public class Class1:IHttpHandler //调用接口
{
public Class1()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
HttpRequest req = context.Request;
if (req.UrlReferrer != null && req.UrlReferrer.Host.Length > 0) //反盗链代码判断
{
System.Drawing.Image img = System.Drawing.Image.FromFile(context.Request.PhysicalPath);
System.Drawing.Graphics g = Graphics.FromImage(img);
g.DrawString("三国演义", new Font("宋体", 20, FontStyle.Bold), Brushes.White, 10, 10);
img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
context.Response.Flush();
context.Response.End();
}
else
{
context.Response.Write("您不能盗链本站图片");
}
}
}
在web.config中注册接口:
<httpHandlers>
<add verb="*" path="images/*.jpg" type="Class1,App_Code"/>
</httpHandlers>
- ASP.NET 图片加水印防盗链
- ASP.NET 图片加水印防盗链
- ASP.NET 图片加水印防盗链
- ASP.NET 图片加水印防盗链
- ASP.NET 图片加水印防盗链实现代码
- asp.net]图片加水印
- asp.net图片加水印
- ASP.NET图片上传,加水印文字和水印图片!
- asp.net 中给图片加水印
- ASP.NET图片上传加水印
- Asp.net给图片加水印
- ASP.NET图片防盗链
- asp.net 图片防盗链
- IHttpHandler处理防盗链和图片加水印
- 图片加水印和防盗链(一)
- ASP图片加水印
- asp.net加水印
- .net图片加水印
- Android如何处理未捕获异常
- Java swing 下拉框
- windows查看端口占用情况
- 禁用鼠标右键js
- Mysql5.5主从复制配置
- ASP.NET 图片加水印防盗链
- ubuntu下rar解压的解决办法
- CABasicAnimation animationWithKeyPath property
- 正则表达式语法
- 设计模式之工厂方法 代码示例
- 向iframe传值
- 页面加载等待遮罩
- ubuntu postfix安装问题及解决办法
- struts2 -- interceptor(如何配置stuts2.xml之Interceptor)