Example #1
0
        public void BuildLinkTest()
        {
            Uri  url =new Uri("http://www.erewr.com/discounttickets/default.aspx?area=hangzhou&topic=t_shanshui&level=4a");
            string type = "area";
            string value = "ningbo";
            UrlParamHelper helper = new UrlParamHelper(url.AbsoluteUri);
            Assert.AreEqual("/ningbo/4a/t_shanshui",helper.BuildLink2(type,value));

            value = "";
            Assert.AreEqual("/4a/t_shanshui", helper.BuildLink2(type, value));
        }
Example #2
0
    //初始化关于url
    private void initurl()
    {
        //第三方登录的处理
        Uri from = Request.UrlReferrer;
        UrlQuery = Request.RawUrl;
        if (from != null)
        {
            if (from.Host == "open.t.qq.com")
            {
                new LoginRedirect();
            }

        }
        urlParamHelper = new CommonLibrary.UrlParamHelper(Request.Url.AbsoluteUri);
        areaSeoName = Request["area"];
        levelname = Request.QueryString["level"];
        topicname = Request.QueryString["topic"];
        countyname = Request.QueryString["county"];
        if (topicname != null)
        {
            topicname = topicname.TrimEnd('/');
            topicname = topicname.Substring(2);
            topic = adotopic.GetTopicBySeoname(topicname);
        }
        if (levelname != null)
        {
            int.TryParse(levelname.TrimEnd('a').TrimEnd('A'), out level);

        }
        if (string.IsNullOrEmpty(countyname))
        {
            pagerGot.UrlRewritePattern = "/Tickets/%area%/%level%/page_{0}.html";
        }
        else
        {
            pagerGot.UrlRewritePattern = "/Tickets/%area%_%county%/%level%/page_{0}.html";
        }
    }
Example #3
0
        public void TestBuildLink2()
        {
            string level="3a";
            string area="hangzhou";
            string url = string.Format("www.tourol.com/default.aspx?area={0}&level={1}", area, level);
            CommonLibrary.UrlParamHelper helper = new UrlParamHelper(url);
            Assert.AreEqual("/hangzhou/4a", helper.BuildLink2("level", "4a"));

             level = "";
             area = "";
             url = string.Format("www.tourol.com/default.aspx");
             helper = new UrlParamHelper(url);
            Assert.AreEqual("/4a", helper.BuildLink2("level", "4a"));

            level = "";
            area = "";
            url = string.Format("www.tourol.com/default.aspx?pgotindex=2");
            helper = new UrlParamHelper(url);
            Assert.AreEqual("/4a", helper.BuildLink2("level", "4a"));

            level = "";
            area = "ningbo";
            url = string.Format("www.tourol.com/default.aspx?area={0}&pgotindex=2",area);
            helper = new UrlParamHelper(url);
            Assert.AreEqual("/ningbo", helper.BuildLink2("area", area));

            level = "4a";
            url ="www.tourol.com/default.aspx?area=hangzhou";
            helper = new UrlParamHelper(url);
            Assert.AreEqual("/hangzhou/4a", helper.BuildLink2("level", level));
        }