------------------------------------------------------------------------------------------------
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
}
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
因篇幅问题不能全部显示,请点此查看更多更全内容