以下的內容是關於C#防盜鏈處理類的內容。htm
public class FileHandler:IHttpHandler
{
public FileHandler()
{
}get
public void ProcessRequest(HttpContext context)
{
if ((context.Request.UrlReferrer == null) || (context.Request.UrlReferrer.Host == "localhost" && context.Request.UrlReferrer.Port == 16490))
{
context.Response.Expires = 0;
context.Response.Clear();
context.Response.ContentType = "rar";
context.Response.WriteFile(context.Request.PhysicalPath);
context.Response.End();
}
{it
HttpResponse response = context.Response;
response.Redirect(context.Request.ApplicationPath + "/ErrorPage.htm");
}io
}
public bool IsReusable
{
get
{
return false;
}
}
}
class