asp.net下結(jié)合HttpHandler實現(xiàn)圖片防盜鏈
更新時間:2010年07月02日 20:00:18 作者:
asp.net防圖片盜鏈HttpHandler
復(fù)制代碼 代碼如下:
#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>
相關(guān)文章
ASP.NET自定義Web服務(wù)器控件之Button控件
這篇文章主要介紹了ASP.NET自定義Web服務(wù)器控件之Button控件,詳細講述了Button控件的實現(xiàn)代碼、前臺頁面的調(diào)用以及對應(yīng)的事件響應(yīng)代碼,具有很好的參考借鑒價值,需要的朋友可以參考下2014-11-11ASP.NET實現(xiàn)Hadoop增刪改查的示例代碼
本篇文章主要介紹了ASP.NET實現(xiàn)Hadoop增刪改查的示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-10-10解決VS2012 Express的There was a problem sending the command to
安裝Visual Studio 2012 Express之后,雙擊打開web.config文件時經(jīng)常出現(xiàn)“There was a problem sending the command to the program”的錯誤,然后VS2012 Express打開了,但web.config文件沒打開,需要再次雙擊web.config文件才能打開。很是煩人2013-02-02asp.net實現(xiàn)的MVC跨數(shù)據(jù)庫多表聯(lián)合動態(tài)條件查詢功能示例
這篇文章主要介紹了asp.net實現(xiàn)的MVC跨數(shù)據(jù)庫多表聯(lián)合動態(tài)條件查詢功能,結(jié)合實例形式較為詳細分析了asp.net基于MVC架構(gòu)的跨數(shù)據(jù)庫多表聯(lián)合查詢功能實現(xiàn)技巧,需要的朋友可以參考下2017-02-02