Beispiel #1
0
        /// <summary>
        /// 获取当前页面包含的站点目录
        /// </summary>
        /// <param name="webPath">网站安装目录</param>
        /// <param name="requestPath">获取的页面,包含目录</param>
        /// <returns>String</returns>
        private string GetCurrPagePath(string webPath, string requestPath)
        {
            //获取URL的虚拟目录(除安装目录)
            string requestFirstPath = GetFirstPath(webPath, requestPath);

            if (requestFirstPath != string.Empty && SiteDomains.GetSiteDomains().Paths.ContainsKey(requestFirstPath))
            {
                return(requestFirstPath);
            }
            return(string.Empty);
        }
Beispiel #2
0
        /// <summary>
        /// 返回域名字典
        /// </summary>
        public static SiteDomains GetSiteDomains()
        {
            SiteDomains _cache = CacheHelper.Get <SiteDomains>(DTKeys.CACHE_SITE_HTTP_DOMAIN);

            lock (lockHelper)
            {
                if (_cache == null)
                {
                    CacheHelper.Insert(DTKeys.CACHE_SITE_HTTP_DOMAIN, new SiteDomains(), 10);
                    instance = CacheHelper.Get <SiteDomains>(DTKeys.CACHE_SITE_HTTP_DOMAIN);
                }
            }
            return(instance);
        }
Beispiel #3
0
 /// <summary>
 /// 获取当前域名包含的站点目录
 /// </summary>
 /// <param name="requestDomain">获取的域名(含端口号)</param>
 /// <returns>String</returns>
 private string GetCurrDomainPath(string requestDomain)
 {
     //当前域名是否存在于站点目录列表
     if (SiteDomains.GetSiteDomains().Paths.ContainsValue(requestDomain))
     {
         string sitePath = SiteDomains.GetSiteDomains().Domains[requestDomain];
         //如果存在,检查是否默认站点,是则还需检查虚拟目录部分
         if (sitePath != SiteDomains.GetSiteDomains().DefaultPath)
         {
             return(sitePath);
         }
     }
     return(string.Empty);
 }
Beispiel #4
0
        /// <summary>
        /// 获取站点的目录
        /// </summary>
        /// <param name="webPath">网站安装目录</param>
        /// <param name="requestPath">获取的页面,包含目录</param>
        /// <param name="requestDomain">获取的域名(含端口号)</param>
        /// <returns>String</returns>
        private string GetSitePath(string webPath, string requestPath, string requestDomain)
        {
            //获取当前域名包含的站点目录
            string domainPath = GetCurrDomainPath(requestDomain);

            if (domainPath != string.Empty)
            {
                return(domainPath);
            }
            // 获取当前页面包含的站点目录
            string pagePath = GetCurrPagePath(webPath, requestPath);

            if (pagePath != string.Empty)
            {
                return(pagePath);
            }
            return(SiteDomains.GetSiteDomains().DefaultPath);
        }