1.关于母版页的引用

  这个项目不同于以往项目引用母版的那种方式,这里是通过在action上面添加属性的方式引用母版如:  [Layout("ArticleMaster")]

  [Layout("ArticleMaster")]
        public void Index()
        {
            // 决定头部文件
            PropertyBag.Add("HeadSign", "article-1");
            string title = "", keywords = "", description = "";
            DealSeo.SetSeoValue("zixun", PropertyBag, title, keywords, description);

            string path = HttpContext.Current.Server.MapPath("/Html") + MGfile.GetFilePath(Utils.GetRemoveUpdateStr(Request.Uri.PathAndQuery), Level.level4);
            bool iscache = Utils.IsFileExits(path, Level.level4);
            if (!iscache)
            {
                calendarDataSet.calendarDataTable tb = calendarDB.GetDateByNow();
                if (tb != null && tb.Rows.Count > 0)
                {
                    calendarDataSet.calendarRow r = tb.Rows[0] as calendarDataSet.calendarRow;
                    PropertyBag.Add("CalendarRow", r);
                }
                PropertyBag.Add("PU", new PageUseMethod());
            }
            string url = Context.Url;
            url = HttpContext.Request.Url.AbsolutePath;
            Utils.DealHtmlPageCache(this, System.Reflection.MethodBase.GetCurrentMethod().Name, path, iscache);
        }

        [Layout("ArticleMaster")]
        public void Channel(int channelID)
        {
            //决定头部文件
            PropertyBag.Add("HeadSign", "article" + channelID);
            string viewname = "";
            switch (channelID)
            {

                case 131://测试 131
                    TestMainPage tmp = new TestMainPage();
                    tmp.FillPage(PropertyBag, channelID);
                    DealSeo.SetSeoValue("ceshi", PropertyBag, "", "", "");
                    viewname = "testmain";
                    RenderView("testmain");
                    break;
                case 29://血型  29
                    DealSeo.SetSeoValue("xuexing", PropertyBag, "", "", "");
                    BloodType bt = new BloodType();
                    bt.FillPage(PropertyBag, channelID);
                    viewname = "bloodtype";
                    RenderView("bloodtype");
                    break;
                case 7://风水 7
                    DealSeo.SetSeoValue("fengshui", PropertyBag, "", "", "");
                    Geomantic gm = new Geomantic();
                    gm.FillPage(PropertyBag, channelID);
                    viewname = "geomantic";
                    RenderView("geomantic");
                    break;
                case 15://开运 15
                    DealSeo.SetSeoValue("kaiyun", PropertyBag, "", "", "");
                    LuckUp lu = new LuckUp();
                    lu.FillPage(PropertyBag, channelID);
                    viewname = "lucky";
                    RenderView("lucky");
                    break;
                case 13://周易 13
                    DealSeo.SetSeoValue("zhouyi", PropertyBag, "", "", "");
                    PropertyBag.Add("channelID", channelID);
                    viewname = "zhouyi";
                    RenderView("zhouyi");
                    break;
                case 34://民俗 34
                    DealSeo.SetSeoValue("minsu", PropertyBag, "", "", "");
                    Folkcustom fk = new Folkcustom();
                    fk.FillPage(PropertyBag, channelID);
                    viewname = "folkcustom";
                    RenderView("folkcustom");
                    break;
                case 24://星座 24
                    DealSeo.SetSeoValue("xingzuo", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    string ConstellationDate = "";
                    string ConstellationDescripe = "";
                    string ConstellationImg = "";
                    string ConstellationName = Utils.GetConstellationName(out ConstellationDate, out ConstellationDescripe, out ConstellationImg);
                    PropertyBag.Add("ConstellationName", ConstellationName);
                    PropertyBag.Add("ConstellationDate", ConstellationDate);
                    PropertyBag.Add("ConstellationDescripe", ConstellationDescripe.Length > 30 ? ConstellationDescripe.Substring(0, 30) : ConstellationDescripe);
                    PropertyBag.Add("ConstellationImg", ConstellationImg);
                    viewname = "astro";
                    RenderView("astro");
                    break;
                case 20://灵异  
                    DealSeo.SetSeoValue("lingyi", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "ghost";
                    RenderView("ghost");
                    break;
                case 14://相学 
                    DealSeo.SetSeoValue("xiangxue", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "look";
                    RenderView("look");
                    break;
                case 193://心理193  处理到此处
                    DealSeo.SetSeoValue("xinli", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "heart";
                    RenderView("heart");
                    break;
                case 21://生肖 
                    DealSeo.SetSeoValue("shengxiao", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "shengxiao";
                    RenderView("shengxiao");
                    break;
                case 192://佛学 
                    DealSeo.SetSeoValue("foxue", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "buddhism";
                    RenderView("buddhism");
                    break;
                case 17://解梦 
                    DealSeo.SetSeoValue("jiemeng", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "dream";
                    RenderView("dream");
                    break;
                default:
                    Response.Redirect("http://www.aqioo.com/urlerror.aspx", true);
                    break;
            }
            string path = HttpContext.Current.Server.MapPath("/Html") + MGfile.GetFilePath(Utils.GetRemoveUpdateStr(Request.Uri.PathAndQuery), Level.level4);
            bool iscache = Utils.IsFileExits(path, Level.level4);
            Utils.DealHtmlPageCache(this, viewname, path, iscache);
        }
View Code

   1.1 ArticleMaster中通过后台 PropertyBag.Add("HeadSign", "article-1");传递过来的HeadSign值选择加载哪个头部

   1.2 点击头部生肖

           <pattern>astro.aqioo.com/shengxiao.html</pattern>

             <replace><![CDATA[/article/channel.html?channelID=21]]></replace>

   1.3 根据传过来的channelID加载文章数据

 [Layout("ArticleMaster")]
        public void Channel(int channelID)
        {
            //决定头部文件
            PropertyBag.Add("HeadSign", "article" + channelID);
            string viewname = "";
            switch (channelID)
            {

                case 131://测试 131
                    TestMainPage tmp = new TestMainPage();
                    tmp.FillPage(PropertyBag, channelID);
                    DealSeo.SetSeoValue("ceshi", PropertyBag, "", "", "");
                    viewname = "testmain";
                    RenderView("testmain");
                    break;
                case 29://血型  29
                    DealSeo.SetSeoValue("xuexing", PropertyBag, "", "", "");
                    BloodType bt = new BloodType();
                    bt.FillPage(PropertyBag, channelID);
                    viewname = "bloodtype";
                    RenderView("bloodtype");
                    break;
                case 7://风水 7
                    DealSeo.SetSeoValue("fengshui", PropertyBag, "", "", "");
                    Geomantic gm = new Geomantic();
                    gm.FillPage(PropertyBag, channelID);
                    viewname = "geomantic";
                    RenderView("geomantic");
                    break;
                case 15://开运 15
                    DealSeo.SetSeoValue("kaiyun", PropertyBag, "", "", "");
                    LuckUp lu = new LuckUp();
                    lu.FillPage(PropertyBag, channelID);
                    viewname = "lucky";
                    RenderView("lucky");
                    break;
                case 13://周易 13
                    DealSeo.SetSeoValue("zhouyi", PropertyBag, "", "", "");
                    PropertyBag.Add("channelID", channelID);
                    viewname = "zhouyi";
                    RenderView("zhouyi");
                    break;
                case 34://民俗 34
                    DealSeo.SetSeoValue("minsu", PropertyBag, "", "", "");
                    Folkcustom fk = new Folkcustom();
                    fk.FillPage(PropertyBag, channelID);
                    viewname = "folkcustom";
                    RenderView("folkcustom");
                    break;
                case 24://星座 24
                    DealSeo.SetSeoValue("xingzuo", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    string ConstellationDate = "";
                    string ConstellationDescripe = "";
                    string ConstellationImg = "";
                    string ConstellationName = Utils.GetConstellationName(out ConstellationDate, out ConstellationDescripe, out ConstellationImg);
                    PropertyBag.Add("ConstellationName", ConstellationName);
                    PropertyBag.Add("ConstellationDate", ConstellationDate);
                    PropertyBag.Add("ConstellationDescripe", ConstellationDescripe.Length > 30 ? ConstellationDescripe.Substring(0, 30) : ConstellationDescripe);
                    PropertyBag.Add("ConstellationImg", ConstellationImg);
                    viewname = "astro";
                    RenderView("astro");
                    break;
                case 20://灵异  
                    DealSeo.SetSeoValue("lingyi", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "ghost";
                    RenderView("ghost");
                    break;
                case 14://相学 
                    DealSeo.SetSeoValue("xiangxue", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "look";
                    RenderView("look");
                    break;
                case 193://心理193  处理到此处
                    DealSeo.SetSeoValue("xinli", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "heart";
                    RenderView("heart");
                    break;
                case 21://生肖 
                    DealSeo.SetSeoValue("shengxiao", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "shengxiao";
                    RenderView("shengxiao");
                    break;
                case 192://佛学 
                    DealSeo.SetSeoValue("foxue", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "buddhism";
                    RenderView("buddhism");
                    break;
                case 17://解梦 
                    DealSeo.SetSeoValue("jiemeng", PropertyBag, "", "", "");
                    PropertyBag.Add("ChannelID", channelID);
                    viewname = "dream";
                    RenderView("dream");
                    break;
                default:
                    Response.Redirect("http://www.aqioo.com/urlerror.aspx", true);
                    break;
            }
            string path = HttpContext.Current.Server.MapPath("/Html") + MGfile.GetFilePath(Utils.GetRemoveUpdateStr(Request.Uri.PathAndQuery), Level.level4);
            bool iscache = Utils.IsFileExits(path, Level.level4);
            Utils.DealHtmlPageCache(this, viewname, path, iscache);
        }
View Code

 

posted on 2014-09-04 13:41  随心所意  阅读(212)  评论(0)    收藏  举报