手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >asp.net下结合HttpHandler实现图片防盗链
asp.net下结合HttpHandler实现图片防盗链
摘要:复制代码代码如下:#regionIHttpHandler成员boolIHttpHandler.IsReusable{get{returntr...

复制代码 代码如下:

#region IHttpHandler 成员

bool IHttpHandler.IsReusable

{

get { return true; }

}

void IHttpHandler.ProcessRequest(HttpContext context)

{

string FileName = context.Server.MapPath(context.Request.FilePath);

if (context.Request.UrlReferrer.Host == null)

{

context.Response.ContentType = "image/JPEG";

context.Response.WriteFile("/no.jpg");

}

else

{

if (context.Request.UrlReferrer.Host.IndexOf("mydomain.com") > 0)

{

context.Response.ContentType = "image/JPEG";

context.Response.WriteFile(FileName);

}

else

{

context.Response.ContentType = "image/JPEG";

context.Response.WriteFile("no/jpg");

}

}

}

#endregion

<httpHandlers>

<add verb="*" path="*.jpg" type="JpgHandler, MyDll" />

</httpHandlers>

【asp.net下结合HttpHandler实现图片防盗链】相关文章:

asp.net ext treepanel 动态加载XML的实现方法

Asp.Net HttpHandler 妙用

asp.net下实现URL重写技术的代码

asp.net(c#)复数类(复数加减乘除四则运算)

asp.net显示页面执行时间

asp.net实现md5加密

asp.net2.0实现邮件发送(测试成功)

asp.net下linkbutton的前后台使用方法

asp.net中利用ashx实现图片防盗链的原理分析

asp.net 1.1/ 2.0 中快速实现单点登陆

精品推荐
分类导航