zoukankan      html  css  js  c++  java
  • 图片盗链


        public class ImageHttpHandler : IHttpHandler
        {
            #region IHttpHandler 成员

            public bool IsReusable {
                get { return true; }
            }

            public void ProcessRequest(HttpContext context) {
                string FileName = context.Server.MapPath(context.Request.FilePath);
                if (context.Request.UrlReferrer == null
                    || string.IsNullOrEmpty(context.Request.UrlReferrer.Host)) {
                    context.Response.ContentType = "image/JPEG";
                    context.Response.WriteFile("~/images/no.gif");//被替换图片
                } else {
                    if (context.Request.UrlReferrer.Host.IndexOf(SiteConfig.Currect.BaseConfig.Domain) > -1) {
                        //这里是你的域名
                        context.Response.ContentType = "image/JPEG";
                        context.Response.WriteFile(FileName);
                    } else {
                        context.Response.ContentType = "image/JPEG";
                        context.Response.WriteFile("~/images/no.gif");
                    }
                }
            }

            #endregion

  • 相关阅读:
    1023. 组个最小数
    1021. 个位数统计
    *1020. 月饼
    *1019. 数字黑洞
    1016. 部分A+B
    *1014. 福尔摩斯的约会
    *1013. 数素数
    *1012. 数字分类
    1011. A+B和C
    *1008. 数组元素循环右移问题
  • 原文地址:https://www.cnblogs.com/hqbird/p/1432138.html
Copyright © 2011-2022 走看看