熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP.NET防盜鏈演示代碼

2013-11-13 10:24:27  來源: .NET編程 

  <%@ WebHandler Language=C# Class=防盜鏈 %>

  using Systemusing SystemWeb

  public class 防盜鏈 IHttpHandler {

  public void ProcessRequest (HttpContext context) { contextResponseContentType = image/JPEGstring fullpath = HttpContextCurrentServerMapPath(~/image/jpgusing (SystemDrawingBitmap bitmap = new SystemDrawingBitmap(fullpath))

  { using (SystemDrawingGraphics g = SystemDrawingGraphicsFromImage(bitmap))

  { if (contextRequestUrlReferrer == null)

  { gClear(SystemDrawingColorWhite)gDrawString(禁止提交圖片 new SystemDrawingFont(宋體 SystemDrawingBrushesRosyBrown } else if(context RequestUserHostAddress !=localhost||context Request UserHostAddress !=

  { gClear(System Drawing Color White )gDrawString(禁止盜鏈new SystemDrawingFont (宋體System Drawing Brushes RosyBrown }

  } bitmapSave(context Response OutputStream System Drawing Imaging ImageFormatGif )}

  public bool IsReusable { get { return false}

  }


From:http://tw.wingwit.com/Article/program/net/201311/13520.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.