<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<!--网站防盗链-->
<img src="images/47578.jpg" />
</div>
</form>
</body>
</html>
------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
/// <summary>
///otherLink 的摘要说明
/// </summary>
public class otherLink:IHttpHandler
{
private const string ERRFILE = "~/images/pagerror.gif";
public otherLink()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
#region IHttpHandler 成员
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
//约定localhost:11222
if (context.Request.UrlReferrer.Host == "localhost" &&
context.Request.UrlReferrer.Port == 11222 )
{
context.Response.Expires = 0;
context.Response.Clear();
FileInfo file = new FileInfo(context.Request.PhysicalPath);
context.Response.AddHeader("Content_Disposition", "filename=" + file.Name);
context.Response.AddHeader("Content_Length", file.Length.ToString());
string fileExtension = file.Extension.ToLower();
switch (fileExtension)
{
case "jpg":
context.Response.ContentType = "image/jpeg";
break;
//......
}
context.Response.WriteFile(context.Request.PhysicalPath);
context.Response.End();
}
else
{
context.Response.WriteFile(context.Request.MapPath(ERRFILE));
context.Response.ContentType = "text/plain";?
context.Response.Write("<a href='http://localhost:11222/Default.aspx'>跳转到原始网站!</a>");
context.Response.End();
}
}
#endregion
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
/// <summary>
///otherLink 的摘要说明
/// </summary>
public class otherLink:IHttpHandler
{
private const string ERRFILE = "~/images/pagerror.gif";
public otherLink()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
#region IHttpHandler 成员
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
//约定localhost:11222
if (context.Request.UrlReferrer.Host == "localhost" &&
context.Request.UrlReferrer.Port == 11222 )
{
context.Response.Expires = 0;
context.Response.Clear();
FileInfo file = new FileInfo(context.Request.PhysicalPath);
context.Response.AddHeader("Content_Disposition", "filename=" + file.Name);
context.Response.AddHeader("Content_Length", file.Length.ToString());
string fileExtension = file.Extension.ToLower();
switch (fileExtension)
{
case "jpg":
context.Response.ContentType = "image/jpeg";
break;
//......
}
context.Response.WriteFile(context.Request.PhysicalPath);
context.Response.End();
}
else
{
context.Response.WriteFile(context.Request.MapPath(ERRFILE));
context.Response.ContentType = "text/plain";?
context.Response.Write("<a href='http://localhost:11222/Default.aspx'>跳转到原始网站!</a>");
context.Response.End();
}
}
#endregion
}
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------