JpgHandler :ZT

using System;
using System.Web;

public class JpgHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string FileName = context.Server.MapPath(context.Request.FilePath);
if (context.Request.ServerVariables["HTTP_REFERER"] == null)
{
context.Response.ContentType = "image/JPEG";
context.Response.WriteFile("/no.jpg");
}
else
{
if (context.Request.ServerVariables["HTTP_REFERER"].IndexOf("mydomain.com") > 0)
{
context.Response.ContentType = "image/JPEG";
context.Response.WriteFile(FileName);
}
else
{
context.Response.ContentType = "image/JPEG";
context.Response.WriteFile("/no.jpg");
}
}
}

public bool IsReusable
{
get
{ return true; }
}
}

posted on 2005-11-07 11:35  老代哥哥  阅读(143)  评论(0编辑  收藏  举报

导航