⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 noleechimagehandler.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.Web
{
    using System;
    using System.Globalization;
    using System.IO;
    using System.Web;

    public class NoLeechImageHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            HttpRequest request = context.Request;
            string physicalPath = request.PhysicalPath;
            if (((request.UrlReferrer != null) && (request.UrlReferrer.Host.Length > 0)) && (CultureInfo.InvariantCulture.CompareInfo.Compare(request.Url.Host, request.UrlReferrer.Host, CompareOptions.IgnoreCase) != 0))
            {
                physicalPath = context.Server.MapPath("~/images/nopic.gif");
            }
            string str2 = null;
            string str4 = Path.GetExtension(physicalPath).ToLower(CultureInfo.CurrentCulture).ToString();
            if (str4 != null)
            {
                if (!(str4 == ".gif"))
                {
                    if (str4 == ".jpg")
                    {
                        str2 = "image/jpeg";
                    }
                    else if (str4 == ".png")
                    {
                        str2 = "image/png";
                    }
                }
                else
                {
                    str2 = "image/gif";
                }
            }
            if (!File.Exists(physicalPath))
            {
                context.Response.StatusCode = 0x194;
            }
            else
            {
                context.Response.StatusCode = 200;
                context.Response.ContentType = str2;
                context.Response.WriteFile(physicalPath);
            }
        }

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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -