Exemple #1
0
        /// <summary>
        /// 返回站点信息
        /// </summary>
        protected Model.sites GetSiteModel()
        {
            string requestDomain = HttpContext.Current.Request.Url.Authority.ToLower(); //获得来源域名含端口号
            string requestPath   = HttpContext.Current.Request.RawUrl.ToLower();        //当前的URL地址
            string sitePath      = GetSitePath(requestPath, requestDomain);

            Model.sites modelt = SiteDomains.GetSiteDomains().SiteList.Find(p => p.build_path == sitePath);
            return(modelt);
        }
Exemple #2
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);
        }
Exemple #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);
 }
Exemple #4
0
        /// <summary>
        /// 获取站点的目录
        /// </summary>
        /// <param name="requestPath">获取的页面,包含目录</param>
        /// <param name="requestDomain">获取的域名(含端口号)</param>
        /// <returns>String</returns>
        private string GetSitePath(string requestPath, string requestDomain)
        {
            //当前域名是否存在于站点目录列表
            if (SiteDomains.GetSiteDomains().Paths.ContainsValue(requestDomain))
            {
                return(SiteDomains.GetSiteDomains().Domains[requestDomain]);
            }

            // 获取当前页面包含的站点目录
            string pagePath = GetFirstPath(requestPath);

            if (pagePath != string.Empty)
            {
                return(pagePath);
            }
            return(SiteDomains.GetSiteDomains().DefaultPath);
        }
Exemple #5
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);
        }
Exemple #6
0
        /// <summary>
        /// 获取链接的前缀
        /// </summary>
        /// <param name="requestPath">当前的URL地址</param>
        /// <param name="requestDomain">获得来源域名含端口号</param>
        /// <returns>String</returns>
        private string GetLinkStartString(string requestPath, string requestDomain)
        {
            string requestFirstPath = GetFirstPath(requestPath);//获得二级目录(不含站点安装目录)

            //检查是否与绑定的域名或者与默认站点的目录匹配
            if (SiteDomains.GetSiteDomains().Paths.ContainsValue(requestDomain))
            {
                return("/");
            }
            else if (requestFirstPath == string.Empty || requestFirstPath == SiteDomains.GetSiteDomains().DefaultPath)
            {
                return(config.webpath);
            }
            else
            {
                return(config.webpath + requestFirstPath + "/");
            }
        }
Exemple #7
0
        /// <summary>
        /// 获取当前页面包含的站点目录
        /// </summary>
        private string GetFirstPath(string requestPath)
        {
            int indexNum = config.webpath.Length; //安装目录长度

            //如果包含安装目录和aspx目录也要过滤掉
            if (requestPath.StartsWith(config.webpath + DTKeys.DIRECTORY_REWRITE_ASPX + "/"))
            {
                indexNum = (config.webpath + DTKeys.DIRECTORY_REWRITE_ASPX + "/").Length;
            }
            string requestFirstPath = requestPath.Substring(indexNum);

            if (requestFirstPath.IndexOf("/") > 0)
            {
                requestFirstPath = requestFirstPath.Substring(0, requestFirstPath.IndexOf("/"));
            }
            if (requestFirstPath != string.Empty && SiteDomains.GetSiteDomains().Paths.ContainsKey(requestFirstPath))
            {
                return(requestFirstPath);
            }
            return(string.Empty);
        }