zoukankan      html  css  js  c++  java
  • [kooboo] 页面层现过程

    看了一下代码,它的页面展现过程的一个大致分析。

    首先看 web.config

     <httpModules>
          <remove name="UrlRoutingModule-4.0"/>
          <add name="UrlRoutingModule-4.0" type="Kooboo.CMS.Sites.Web.FrontUrlRoutingModule,Kooboo.CMS.Sites"/>
          <add name="KoobooCMSResponseHeader" type="Kooboo.CMS.Sites.Web.KoobooCMSResponseModule,Kooboo.CMS.Sites"/>
          <add name="StartPagePublishingJob" type="Kooboo.CMS.Sites.Services.StartPagePublishingJobModule,Kooboo.CMS.Sites"/>
        </httpModules>

    第一步,特别是 Kooboo.CMS.Sites.Web.FrontUrlRoutingModule 这个,基本代码如下:

    对context进行包装,
    1. protected override void Init(HttpApplication application)
    2.         {
    3.             application.PostResolveRequestCache += new EventHandler(application_PostResolveRequestCache);
    4.         }
    5.  
    6.         void application_PostResolveRequestCache(object sender, EventArgs e)
    7.         {
    8.             HttpContextBase context = new FrontHttpContextWrapper(((HttpApplication)sender).Context);
    9.             this.PostResolveRequestCache(context);
    10.             //if (Site.Current != null)
    11.             //{
    12.             //    UrlRedirect(context);
    13.             //}
    14.         }

    FrontHttpContextWrapper , 对httpRequest 及 httpRespone 进行了包装。

    附 :81291_2_thumb[6]

    关于 httpModule 与 HttpHander 异同参见:http://www.cnblogs.com/cyan/archive/2009/02/04/1383580.html

    2,根据  Kooboo.Web.Mvc.Routing.RouteTableRegister.RegisterRoutes(routes); 所设置的路由,将请求路由至相关的 Area  , controller 及action

    配置于 routes.config 中,

    其它的我们先不关心,我们从

    <add name="Page" url="{*PageUrl}">
         <defaults controller = "Page" action = "Entry" PageUrl=""></defaults>
         <dataTokens Namespaces="Kooboo.CMS.Sites.Controllers.Front"/>
       </add>

    开始起步。

    在上面的路由中的设置,除了忽略列表中的,以及上面没有匹配到的所有的 url 都会被  Page.Entry() 处理。

    3,开始进入的最广泛的代码处理了。

     public class PageController : FrontControllerBase
        {
            public Page_Context PageContext
            {
                get
                {
                    return Page_Context.Current;
                }
            }
            [SiteOfflinedFilter(Order = 0)]
            [CustomRedirectFilter(Order = 5)]
            [PageExecutionFilter(Order = 10)]
            [OutputCacheFilter(Order = 15)]
            public virtual ActionResult Entry()
            {
     //.....
    }
    }

    可见 , Page 派生自 FrontController, Front暂时我们不理会他们吧。

    Entry 被加上了几个Filter,

    siteofflined 判断这个系统是否在线上,否则。。。。

    CustonRedirect : 对应于用户自定义的跳转。

    PageExecutionFilter: 初始化页面层现的参数,PageContext, Page,Site 等。

    OutputCacheFilter:设置浏览器及服务器端页面缓存

    4,进入 Entry内部

    1.       var actionResult = Page_Context.Current.ExecutePlugins();   插件,
    2.    Page_Context.Current.ExecuteDataRules();   执行数据, 放于 ViewState【】 中,
    3. Page_Context.Current.InitializeTitleHtmlMeta(); 页面中 HtmlMeta
    4.   

      if (Page_Context.Current.ExecuteModuleControllerAction())
                 {
                     return ViewPage();
                 }

      如果 ModelController 的

        actionResult is FileResult
                     || actionResult is PartialViewResult
                     || actionResult is JsonResult
                     || actionResult is ContentResult
                     || actionResult is JavaScriptResult
                     || actionResult is RedirectToRouteResult;

      直接返回结果

      否则 ViewPage….


       

  • 相关阅读:
    链表的逆置(无聊而写)
    C
    大型分布式站点的技术需求
    leetcode第一刷_Best Time to Buy and Sell Stock
    微商行业面临洗礼,微盟萌店是否能完毕“神补刀”?
    oracle函数 CONCAT(c1,c2)
    oracle函数 CHR(n1)
    oracle函数 ASCII(x1)
    oracle函数 INTERVAL c1 set1
    oracle函数 SESSIONTIMEZONE
  • 原文地址:https://www.cnblogs.com/zbw911/p/2867497.html
Copyright © 2011-2022 走看看