1 public void ProcessRequest (HttpContext context) {
2 context.Response.ContentType = "image/jpeg";
3
4 //判断当前你上页面 url和当前网站的地址是否是一个域名和端口
5
6 var refUrl = context.Request.UrlReferrer;
7 var reuqestUrl = context.Request.Url;
8 // http://www.baidu.com/a.aspx
9 //http://www.baidu.com/b/a.jpeg;
10
11 if(Uri.Compare(refUrl, reuqestUrl, UriComponents.HostAndPort, UriFormat.SafeUnescaped,
12 StringComparison.CurrentCulture)==0)
13 {
14 // 当前网站访问我们的图片
15 context.Response.WriteFile("DSC_0067-bak.jpg");
16 }
17 else
18 {
19 //如果不是
20
21 System.Drawing.Bitmap bitmap = new Bitmap(200,200);
22 using (Graphics graphics = Graphics.FromImage(bitmap))
23 {
24 graphics.DrawString("shit",new Font(new FontFamily("黑体"),30 ),new HatchBrush(HatchStyle.Wave, Color.Red),2,2 );
25
26 bitmap.Save(context.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
27 }
28 }
29
30
31 }