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


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

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

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;
}
}
}




 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄