示例#1
0
        private SiteUrls()
        {
            Urls = new ArrayList();
            Paths = new NameValueCollection();

            UrlRewriteBll bll = new UrlRewriteBll();
            List<UrlRewrite> ls = bll.GetList("");
            foreach (UrlRewrite entity in ls)
            {
                Paths.Add(entity.name, entity.path);
                entity.page = entity.page.Replace("^", "&");
                entity.querystring = entity.querystring.Replace("^", "&");
                Urls.Add(entity);
            }
        }
示例#2
0
 /// <summary>
 /// 返回URL重写统一链接地址
 /// </summary>
 protected string linkurl(string _key, params object[] _params)
 {
     Hashtable ht = new UrlRewriteBll().GetList();
     UrlRewrite entity = ht[_key] as UrlRewrite;
     if (entity == null)
     {
         return "";
     }
     try
     {
         string _result = string.Empty;
         string _rewriteurl = string.Format(entity.path, _params);
         switch (config.staticstatus)
         {
             case 1: //URL重写
                 _result = config.webpath + _rewriteurl;
                 break;
             case 2: //全静态
                 _rewriteurl = _rewriteurl.Substring(0, _rewriteurl.LastIndexOf(".") + 1);
                 _result = config.webpath + SysKeys.DIRECTORY_REWRITE_HTML + "/" + _rewriteurl + config.staticextension;
                 break;
             default: //不开启
                 string _originalurl = entity.page;
                 if (!string.IsNullOrEmpty(entity.querystring))
                 {
                     _originalurl = entity.page + "?" + Regex.Replace(_rewriteurl, entity.pattern, entity.querystring, RegexOptions.None | RegexOptions.IgnoreCase);
                 }
                 _result = config.webpath + _originalurl;
                 break;
         }
         return _result;
     }
     catch
     {
         return "";
     }
 }