DotNetNuke Skinning Whitepaper 翻译记录(页面处理部分)
页面处理
DotNetNuke 使用单一的 ASPX 页面 ( Default.aspx ) 来展示所有的控件和内容。这样做的好处有两个。首先由户界面管理逻辑集中到了一个单一的页面上,其次是坚少了应用程序的入口,增强了方案的安全性。Default.aspx只有很有限的功能 –包含页面管理的<HEAD> 元素、包含用来放置皮肤的占位符。
当用户第一次访问DotNetNuke 应用程序的时候, 首先检查从用户浏览器发来的 URL 和 request header(怎么翻??), 确定所用的皮肤. 这个过程需要访问数据库中的Skins表,这个表里包含了所有的皮肤和容器的使用分配表。 分配表以等级的方式存储这样子分配就可以覆盖父分配 (例如,分页级别的皮肤设置应该覆盖站点级别的皮肤设置).核心程序通过有效的对象缓存来减少由于获取当前皮肤设置而访问数据库对性能的影响。
一旦皮肤确定,相关的用户控件就可以动态的加载并安置到页面上的占位符上。每一个使用皮肤的空间都要引用保存在\adimin\Skins文件夹里的skin.vb文件。这个文件负责皮肤处理中的所有工作:安全管理、加载内容。
Page Processing
DotNetNuke uses a single ASPX page ( Default.aspx ) for rendering all controls and content. The benefit of this approach is two-fold. First it centralizes all of the logic for management of the user interface in a single page. Second it reduces the number of entry points into the application which results in a far more secure solution. The Default.aspx has very limited logic – it includes code for managing the page <HEAD> elements and includes a placeholder for injecting the skin.
When a user first enters the DotNetNuke application, it examines the URL and request header it receives from the user's browser, to determine which skin it should use. This process requires a database request to the Skins table where all of the assignments for skins and containers are stored. The assignments are stored in a hierarchical manner so that child assignments are able to override parent assignments ( ie. a skin applied at the tab level should override a skin applied at the portal level ). The performance implication of making a database request to retrieve the current skin assignment for the page and modules is mitigated by efficient data object caching within the core application.
Once the skin is identified, the associated user control is loaded dynamically and injected into the page placeholder. Every skin user control must reference a common skin.vb code-behind file stored in the \admin\Skins folder. This file performs all of the skin processing for managing security and injecting content.