Document directory
- Deployment that can be copied by Portal Starter Kit
- Dynamic operation principle of the portal website engine
- Portal website settings XML Scheme
- Context object setting
- Role groups and Models
- Under Portal Starter Kit
- Chinese version of ASP. NET Starter Kit
ASP. NET Starter Kit: Enter and develop: Where can I copy the Portal Starter Kit?
Author: Zhou Shixiong
October 2003
Deployment that can be copied by Portal Starter Kit
It's time for programming to "dig, where can I copy the Portal Starter Kit (Entry Site entry Portal package) of the US micro-engine for development, free trial, and release of the original program? The following examples are available:
- The dynamic working principle of the portal website engine.
- Configure the Context object logging interface.
- ASP. NET three-way architecture.
- Supports the ASP. NET mobile controls, the built-in render manager for the Pocket PC, and the WAP/WML encryption method for other dynamic upload methods.
Dynamic operation principle of the portal website engine
The dynamic operation principle of the portal website engine is as follows:
- Fetch the portal website XML to set the destination to the context object: The global domain will be uploaded every time the website is retrieved. the ASA application_beginrequest sub-program, in which the XML Parser of the portal website is stored in the context object. The new () and getsitesettings () of/components/configuration. VB will be called ().
- The following figure shows the topology and modulo groups: the default. aspx line is displayed, and the default. aspx line is set to topdefault. aspx. For example, topdefault. aspx retrieves the portal website settings of the context object to display the topology and various schemas.
Portal website settings XML Scheme
The configuration of the entire portal website is not saved to the resource, but stored in the XML example (PortalCfg. xml.
For example, the [employee ticket] is attached to PortalCfg. xml:
~ /Images/image19.jpg
300
400
As for [employee ticket], the following statement is displayed:
For example, [administrator] refers to the section of PortalCfg. xml:
As described in [administrator], each module is shown as follows:
For example, the module is defined in PortalCfg. xml:
...
As shown in the following figure:
Context object setting
The first step of the dynamic operation principle of the portal website engine is to set the parameters to the Context object for retrieving the portal website XML. Portal Starter Kit uses a special technique to store the settings of the Context object into the Portal and store the settings of the Portal website in XML library (PortalCfg. xml) into the Context object. The method is Global. in the asa Application_BeginRequest () Sub-program, after the XML parameter settings of the portal website are stored in the Context object, any website, component, and control component in all the websites with the same Request can call the PortalSettings class in the Context object to retrieve the parameter value.
Application_BeginRequest sub-program:
Sub application_beginrequest (byval sender as object, byval e as eventargs) dim tabindex as integer = 0 dim Tabid as integer = 1 'to obtain the condition when index if not (request. params ("tabindex") is nothing) Then tabindex = CINT (request. params ("tabindex") end if 'gets the response Token Generation if not (request. params ("Tabid") is nothing) Then Tabid = CINT (request. params ("Tabid") end if 'httpcontext. current. the cache (cache memory) is stored in the XML file of the website, all programs with the same request can access the 'stored portalsettings settings' to the context object cache (Cache reporter ), httpcontext. current. items ("portalsettings") gets portalsettings settings (portal website settings) context. items. add ("portalsettings", new portalsettings (tabindex, Tabid) 'Save sitesettings settings (Modulo settings) to the context object cache (Cache reporter ), httpcontext. current. items ("sitesettings") obtains sitesettings settings (MOD) dim config as configuration = new configuration () context. items. add ("sitesettings", config. getsitesetask() Try if not (request. userages is nothing) then'request. userages (0) = "ZH-tw" thread. currentthread. currentculture = cultureinfo. createspecificculture (request. userages (0) else 'if no user speaks, it is set to English letters thread. currentthread. currentculture = new cultureinfo ("En-us") end if thread. currentthread. currentuiculture = thread. currentthread. currentculture catch ex as exception thread. currentthread. currentculture = new cultureinfo ("En-us") end tryend sub
"Dim config As Configuration = New Configuration ()" will call the New () Sub-Program of/Components/Configuration. vb:
Public Sub New (ByVal tabIndex As Integer, ByVal tabId As Integer) 'gets the Configuration item Dim config As Configuration = New Configuration () Dim siteSettings As SiteConfiguration = config. getSiteSettings () 'is sorted by TabOrder and sorted by sequence. Set Dim tRow As SiteConfiguration. tabRow For Each tRow In siteSettings. tab. select ("", "TabOrder") Dim tabDetails As New TabStripDetails () With tabDetails. tabId = tRow. tabId. tabName = tRow. tabName. tabOrder = tRow. tabOrder. authorizedRoles = tRow. accessRoles End With Me. optional toptabs. add (tabDetails) Next 'If the selected replicate indexes index (PortalSettings. activeTab) is 0, which is changed to the first TabID 'ctype (Me. optional toptabs (0), TabStripDetails ). tabId = 1 If Me. activeTab. tabId = 0 Then Me. activeTab. tabId = CType (Me. optional toptabs (0), TabStripDetails ). tabId End If 'is sorted by TabOrder, and then the sequence is used to take the row's dynamic setting (Mobile) sequence to set the Dim mRow As SiteConfiguration. tabRow For Each mRow In siteSettings. tab. select ("ShowMobile = 'true'", "TabOrder") Dim tabDetails As New TabStripDetails () With tabdetails. tabId = mRow. tabId. tabName = mRow. mobileTabName. authorizedRoles = mRow. accessRoles End With Me. mobileTabs. add (tabDetails) Next 'modules take the Module Information (Dim activeTab As SiteConfiguration) of the selected modules (Active Tab. tabRow = siteSettings. tab. findByTabId (tabId) Dim moduleRow As SiteConfiguration. _ ModuleRow 'get Modules for this Tab based on the Data Relation For Each moduleRow In activeTab. getModuleRows () Dim moduleSettings As New moduleSettings () With moduleSettings. moduleTitle = moduleRow. moduleTitle. moduleId = moduleRow. moduleId. moduleDefId = moduleRow. moduleDefId. moduleOrder = moduleRow. moduleOrder. tabId = tabId. paneName = moduleRow. paneName. authorizedEditRoles = moduleRow. editRoles. cacheTime = moduleRow. cacheTimeout. showMobile = moduleRow. showMobile 'gets the ModuleDefinition data Dim modDefRow As SiteConfiguration. moduleDefinitionRow = siteSettings. moduleDefinition. findByModuleDefId (. moduleDefId) 'url. required topsrc = modDefRow. optional topsourcefile. mobileSrc = modDefRow. mobileSourceFile End With Me. activeTab. modules. add (moduleSettings) Next 'modulo Order (by ModuleOrder) Me. activeTab. modules. sort () 'obtains the Global information of the case from the first line.
Dim globalSettings As SiteConfiguration. globalRow = siteSettings. global. rows (0) 'fetch Portal global settings Me. portalId = globalSettings. portalId Me. portalName = globalSettings. portalName Me. alwaysShowEditButton = globalSettings. alwaysShowEditButton Me. activeTab. tabIndex = tabIndex Me. activeTab. tabId = tabId Me. activeTab. tabOrder = activeTab. tabOrder Me. activeTab. mobileTabName = activeTab. mobileTabName Me. activeTab. authorizedRoles = activeTab. accessRoles Me. activeTab. tabName = activeTab. tabName Me. activeTab. showMobile = activeTab. showMobileEnd Sub
"Config. getSiteSettings () will call/Components/Configuration. in the GetSiteSettings () function of vb, the interface is stored in the XML file of the website and is set to cache HttpContext. current. cache:
'Get the portal website XML response and set the website public function getsitesettings () as siteconfiguration dim sitesettings as siteconfiguration = ctype (httpcontext. current. cache ("sitesettings"), siteconfiguration) 'If siteconfiguration is not stored in the cache (Cache reporter), the XML format is used in the cache. if sitesettings is nothing then ', the dataset sitesettings = new siteconfiguration () 'Get the XML preset sequence location' to the Web. config fetch location set configfile () 'Configurationsettings. appSettings ("configFile") = "/PortalVBVS3/PortalCfg. xml "'configfile =" C:/Program Files/ASP. NET Starter Kits/ASP. NET Portal (VBVS)/PortalVBVS3/PortalCfg. xml "Dim configFile As String = HttpContext. current. server. mapPath (ConfigurationSettings. appSettings ("configFile") With siteSettings 'sets the AutoIncrement attribute to true to facilitate addition of data. tab. tabIdColumn. autoIncrement = True. _ Module. moduleIdColumn. autoIncrement = True. moduleDefinition. moduleDefIdColumn. autoIncrement = true' expect DataSet siteSettings to be imported into XML. readXml (configFile) End With 'register the dataset to cache HttpContext. current. cache. insert ("sitesetency", sitesetency, New CacheDependency (configFile) End If Return siteSettingsEnd Function
Have you learned the Context object skills?
Role groups and Models
The second step of the dynamic operation principle of the portal website engine shows the association and various modules. The specified topdefault. aspx parameter indicates the parameter and each mode. The operation principle is as follows:
- : The desktopportalbanner. ascx included in the topdefault. aspx parameter indicates that the information is sent to datalist.
- Displays the various models: the working principle controls web users (. the upper topdefault mode of ascx. aspx uses "parent. controls. add (portalmodule) "adds a module to the webpage.
After the Application_BeginRequest sub-Program of the Global. asa row is merged, the Default. aspx row is placed in the parent row, and the non-dynamic parent is set to the parent topdefault. aspx:
Private Sub Page_Load (ByVal sender As System. object, ByVal e As System. eventArgs) Handles MyBase. load 'by Request. browser ("IsMobileDevice") determines whether the user's email is set If Request. browser ("IsMobileDevice") = "true" Then "if you set the parameter for a row, redirect it to MobileDefault. aspx Response. redirect ("MobileDefault. aspx ") else' returns to TimeEntry if it is a normal computer (not an active device. aspx Response. redirect ("Publish topdefault. aspx ") End IfEnd Sub
For example, topdefault. aspx retrieves the portal website settings of the Context object to display the topology and various schemas.
By topdefault. the role topportalbanner included in aspx. ascx has been used to indicate that zookeeper, too topportalbanner. the related program of ascx is as follows. check whether there is a permission limit for every region. After the resource is uploaded to the specified region datalist:
Private Sub Page_Load (ByVal sender As System. object, ByVal e As System. eventArgs) Handles MyBase. load 'by the Context object (HttpContext. current. items ("PortalSettings") gets PortalSettings settings (portal site settings) Dim _ portalSettings As PortalSettings = CType (HttpContext. current. items ("PortalSettings"), PortalSettings) 'portal website name, saved in XML format
| "'If you use a table to log on to the certificate, the logout result if context is displayed. user. identity. authenticationtype = "forms" then logofflink = "|" & controlchars. CR & "logout" & "" end if showtabs = true then tabindex = _ portalsettings. activetab. tabindex 'authorization indicates the dim authorizedtabs as new arraylist () dim addedtabs as integer = 0 dim I as integer for I = 0 to _ portalsettings. optional toptabs. count-1 dim tab as tabstripdetails = ctype (_ portalsettings. when toptabs (I), tabstripdetails) 'checks whether there is a permission limit for every region if portalsecurity. isinroles (tab. authorizedroles) Then authorizedtabs. add (Tab) end if addedtabs = tabindex then tabs. selectedindex = addedtabs end if addedtabs + = 1 next I 'item summary exceed tabs. datasource = authorizedtabs tabs. databind () end ifend sub
In Security. vb, IsInRole () checks whether there is a permission to restrict access to the related programs of each region, as shown below:
Public Shared Function IsInRole(ByVal role As String) As Boolean Return HttpContext.Current.User.IsInRole(role)End Function
Then upload topdefault. the aspx metric shows each mode. Based on the settings of the portal site XML file, this mode selects the mode (. ascx) is added to the layout of the left-side Navigation Pane, center pane, and right-side navigation pane. the related program of aspx is as follows:
Private sub page_init (byval sender as system. object, byval e as system. eventargs) handles mybase. init 'by the context object (httpcontext. current. items ("portalsettings") gets portalsettings settings (portal site settings) dim _ portalsettings as portalsettings = ctype (httpcontext. current. items ("portalsettings"), portalsettings) 'checks whether the guest has the permission to access your website. If there is no permission, the user attempts to access the accessdenied again. aspx, _ portalsettings. activetab. authorizedroles = "all users;" rule table If portalsecurity. isinroles (_ portalsettings. activetab. authorizedroles) = false then response. Redirect ("~ /Admin/accessdenied. aspx ") end if 'if you have not yet logged on to the credential, a logon mode (signin) is inserted. ascx) to the left pane of the first region if request. isauthenticated = false and _ portalsettings. activetab. tabindex = 0 then leftpane. controls. add (page. loadcontrol ("~ /Topics topmodules/signin. ascx ") leftpane. visible = true end if 'According to the portal site XML layout case, add the modulus of the selected webpage to the left pane, if _ portalsettings. activetab. modules. count> 0 then dim _ modulesettings as modulesettings for each _ modulesettings in _ portalsettings. activetab. modules dim parent as control = page. findcontrol (_ modulesettings. panename) 'If this mode is not stored in the cache, a new user control instance is created and the instance is automatically added to this network if _ modulesettings. cachetime = 0 then dim portalmodule as portalmodulecontrol = ctype (page. loadcontrol (_ modulesettings. desktopsrc), portalmodulecontrol) portalmodule. portalid = _ portalsettings. portalid portalmodule. moduleconfiguration = _ modulesettings parent. controls. add (portalmodule) else dim portalmodule as new cachedportalmodulecontrol () portalmodule. portalid = _ portalsettings. portalid portalmodule. moduleconfiguration = _ modulesettings parent. controls. add (portalmodule) end if 'to add a blank row of parent. controls. add (New literalcontrol ("") parent. visible = true next _ modulesettings end ifend sub
Fun?
Under Portal Starter Kit
The English version of Portal Starter Kit can be downloaded and used on the following websites, including the original website:
Http://www.asp.net/Default.aspx? Tabindex = 9 & tabid = 47
Chinese version of ASP. NET Starter Kit
The Chinese version of ASP. NET Starter Kit can be found in the "Community region under MSDN", without additional downloading and usage:
Http://www.microsoft.com/taiwan/msdn/downloads/default.htm
You can also obtain all the Chinese version of the entry kits and architecture white skins at a time through the. NET Enterprise Website tips provided by the MSDN subscriber. Please refer to the following link:
Http://www.microsoft.com/taiwan/msdn/promo/
Trackback: http://tb.blog.csdn.net/TrackBack.aspx? PostId = 165122