C#防盗链处理类的代码

如下的内容是关于C#防盗链处理类的内容。


public class FileHandler:IHttpHandler
{
public FileHandler()
{
}

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();
}
{

HttpResponse response = context.Response;
response.Redirect(context.Request.ApplicationPath + "/ErrorPage.htm");
}

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




猜你喜欢

转载自www.cnblogs.com/tozgb/p/10774624.html