The table in this topic details the steps performed while an XAF ASP.NET application is running.

Note

Currently, only the steps that are performed until the main page is shown are detailed.

Stage Description Ways to Interfere
Application is requested See ASP.NET Application Creation and Initialization.  
An end-user is authenticated See User Authentication using a Logon Window in ASP.NET Applications and User Authentication Without a Logon Window in ASP.NET Applications.  
Start-up Pop-up Window Show Actions are executed. A collection of Pop-up Window Show Actions is populated by the Actions that are registered as start-up Actions in modules used by the application. For instance, the ChangePasswordOnLogon represents a start-up Action. A pop-up window is displayed for each Action after an end-user has executed or canceled the previous Action. To register an Action as a start-up, override the GetStartupActions method in your module class. Return a list of Pop-up Window Show Actions in this method (see PopupWindowShowAction).
Start-up window is shown See Show the Main Page in ASP.NET Applications.  

ASP.NET Application Creation and Initialization

This topic details the steps performed after an end-user has requested an XAF ASP.NET application, until the moment the main XAF objects, like the WebApplication, are created and initialized.

In the following image, you can see that the entire process of the application initialization can be divided into five steps.

The table below describes all these steps in detail.

Stage Description Ways to Interfere
A Web Application is created At the beginning of a request that begins a new session, an instance of the WebApplicationclass is created. This is performed by the Global.Session_Start method, automatically generated in your ASP.NET application project.  
Initial Application Initialization A newly created application is initialized. The settings that are specified in the configuration file's appSettings section are read to the application:  
 

The XafApplication.TablePrefixes property is set to the value assigned to the TablePrefixeskey in the configuration file.

If it is not necessary for you to set table prefixes in the configuration file, you can do it in code. To do this, set the TablePrefixesproperty after an application object has been created, but before its XafApplication.Setup method is called.

 

The location to be used to store the Model.User.xafml file is specified by the UserModelDiffsLocation key.

 
 

The location to be used to store the application's Log file is specified by the TraceLogLocation key.

 
Application Initialization by the Designer Then, the application is initialized by the values specified in the Application Designer. This is performed by the InitializeComponent method, automatically called in the WebApplication constructor.  
 

The XafApplication.Modules collection is populated by the modules added to the Modulessection in the Designer. Each module is set up. This means that the current WebApplication.Instance is assigned to the ModuleBase.Application property.

If you need to add a module that is not registered in the Toolbox, and thus cannot be added via the Designer, use one of the following approaches.

Specify the required module name(s) in the application project's configuration file. Pass this string as a parameter of the XafApplication.Setup method in the Global.Seesion_Start method.

Add this module to the module that is contained in your solution. To do this, use the ModuleBase.RequiredModuleTypes collection.

To see code samples of both these approaches, refer to the Ways to Register a Module topic.

You can perform custom actions with a module, in addition to setting the Application object. To do this, override the module's ModuleBase.Setup method.

 

The XafApplication.Connection property is set to the object of the type specified in the Designer's Connection section. The connection string is specified in the Properties grid, when the Connection section is selected.

You can avoid the use of the Designer applying one of the following techniques.

Specify the connection string in the application project's configuration file. Assign this string to the XafApplication.ConnectionStringproperty (see this property's description).

Set the XafApplication.Connection and/or XafApplication.ConnectionString property before the XafApplication.Setup method is called.

 

The XafApplication.Security property is set to the object of the type specified in the Designer's Security section. The authentication strategy to be used by the Security System is specified in the same section. The User type to be used by the Security System is specified in the Properties grid, when the Security section is selected.

The eXpressApp Framework supplies two security system types: SecuritySimple and SecurityComplex. You can set them using the Application Designer. If you need to use a security of a custom type that implements the ISecurity interface, create and assign it to the XafApplication.Security property in code, before the XafApplication.Setup method is called. If you need to use a custom authentication strategy or a custom User type, initialize them and the XafApplication.Security property, before the XafApplication.Setup method is invoked.

If you don’t initialize a security system via the Application Designer or in code, a SecurityDummy will be used. This security type allows all operations with all types of objects. That's why the presence of the security system is invisible when you run an application.

 

The XafApplication.ApplicationName property is set to the value that is specified in the Properties grid when the Application section is selected.

You can assign a custom value to the XafApplication.ApplicationName property in code - before the XafApplication.Setup method is called.
The application instance is stored in the current Session. An instance of your WebApplication component is assigned to a Session variable named SessionApplicationVariable. This is performed via the WebApplication.SetInstance method invoked in the Global.Session_Start method that is automatically generated in your ASP.NET application project. When the Session is abandoned or times out, the WebApplication instance is disposed of.  
Application Initialization by the Setupmethod The XafApplication.Setup method is called. This is performed by the Global.Session_Startmethod, automatically generated in your ASP.NET application project.
There are several overloads of the Setup method. By default, the method without parameters is called. It leaves the properties that are already initialized as they are and proceeds with the initialization process using default values:
You can call the Setup method with the required parameters, dependent on what objects you need created in a custom way. However, we recommend that you use the approaches presented above, instead.
 

A default Object Space Provider (see XafApplication.ObjectSpaceProvider) is created using a connection string specified by the XafApplication.ConnectionString property.

To create a custom Object Space Provider, subscribe to the XafApplication.CreateCustomObjectSpaceProvider event before the Setupmethod is called. Alternatively, pass the required ObjectSpaceProvider object using the Setup method as a parameter.
You can override the XAFApplication.CreateDefaultObjectSpaceProvider method in your WebApplication class descendant. This method is called when none of the custom approaches to pass an Object Space Provider are used. This method creates an instance of a built-in ObjectSpaceProviderThreadSafe class. You can return an instance of another class that implements the IObjectSpaceProvider interface.
 

A default Controllers Manager (ControllersManager) is created. This object contains a collection of all the Controllers that are declared in the registered modules.

You can override the XAFApplication.CreateControllersManager method in your WebApplication class descendant. This method creates an instance of the built-in ControllersManager class. You can return an instance of another class.
 

A default Modules Manager (ApplicationModulesManager) is created. This object contains the Modules collection along with the modules to be used by the application. This collection is populated by modules from the XafApplication.Modules collection. In addition, the SystemModule is added as a default module.

You can override the XAFApplication.GetDefaultModuleTypes method in your WebApplication class descendant. This method creates an instance of the built-in ApplicationModulesManager class. You can return an instance of another class.
In addition, you can override the GetDefaultModuleTypes method to return modules to be added to an application by default, in addition to the System module.
 

A default Application Model Differences Store (FileModelStore) is created.

If you need to store Application Model's differences in a place that is different from an XafML file, you can create a custom Application Model Differences Store. To do this, subscribe to the XafApplication.CreateCustomModelDifferenceStore event before the Setupmethod is called, or override the CreateModelDifferenceStoreCore method in your WebApplication class descendant.
 

The Object Space Provider and Controllers Manager are assigned to the application's corresponding properties: XafApplication.ObjectSpaceProvider and ControllersManager.

Subscribe to the XafApplication.SettingUp event, to customize objects to be assigned to the application object. Use the event handler's parameters to access the required objects.
 

The modules from the Modules Manager's Modules collection are added to the XafApplication.Modules collection of the current application, since at this step, the latter collection includes the modules that are only added via the Application Designer.

 
 

The Application Model Manager (ApplicationModelsManager) that manages the creation and initialization of the Application Model is instantiated.

 
 

The Application Model is created. Internally, the Application Model has a layered structure. So, at first, the actual layers that comprise the Application Model internals are created:

 
 

The zero layer of the Application Model is created. Initially it is empty. It is filled with data on demand, during an application's life cycle.

To extend the Application Model, pass the required model interfaces via the application modules' ModuleBase.ExtendModelInterfacesmethods. Alternatively, you can implement the IModelExtender interface in Controllers. To modify existing node generators, implement a generator updater and register it via the ModuleBase.AddGeneratorUpdaters method of a module. For details, refer to the Extend and Customize the Application Model in Code topic.
 

A layer for each module used in the application is created. This layer is filled with data from the Model.DesignedDiffs.xafml file that contains Application Model differences made in a particular module.

To modify this layer's data, modify the required module's XafML file. This can be done, for example, via the Model Editor.
 

A layer for the application project is created. This layer is filled with data from the Model.xafml file that contains Application Model differences made in the application project.

To modify this layer's data, modify the application project's XafML file. This can be done, for example, via the Model Editor.
 

Second, all the created layers are wrapped with the master layer.

The master layer does not contain any information itself. It serves as a proxy to all other layers. Usually, when you access the Application Model, you deal with the master layer.
 

The final state of the Application Model is assigned to the XafApplication.Model property. Note that in ASP.NET Web XAF applications, the common part of the Application Model is represented by a single instance, shared between the users.

Subscribe to the XafApplication.SetupComplete event, to create extra objects (helpers, extractors, etc.) after the application has been entirely initialized.
Note

If the current Session has expired, it is restarted, which leads to the re-creation and re-initialization of the WebApplication object.

 

ASP.NET Application Life Cycle的更多相关文章

  1. ASP.NET Application and Page Life Cycle

    ASP.NET Application Life Cycle Overview for IIS 7.0 https://msdn.microsoft.com/en-us/library/bb47025 ...

  2. How to increase timeout for your ASP.NET Application ?

    How to increase timeout for your ASP.NET Application ? 原文链接:https://www.techcartnow.com/increase-tim ...

  3. Debug your ASP.NET Application while Hosted on IIS

    转摘:http://www.codeproject.com/Articles/37182/Debug-your-ASP-NET-Application-while-Hosted-on-IIS This ...

  4. ASP.NET Application,Session,Cookie和ViewState等对象用法和区别 (转)

    在ASP.NET中,有很多种保存信息的内置对象,如:Application,Session,Cookie,ViewState和Cache等.下面分别介绍它们的用法和区别. 方法 信息量大小 作用域和保 ...

  5. Custom ASP.NET Application into SharePoint --整合ASP.NET应用程序到SharePoint

    转:http://www.devexpertise.com/2009/02/18/integrating-a-custom-aspnet-application-into-sharepoint-par ...

  6. [转]ASP.net Application 生命周期事件

    生命周期事件和 Global.asax 文件 在应用程序的生命周期期间,应用程序会引发可处理的事件并调用可重写的特定方法.若要处理应用程序事件或方法,可以在应用程序根目录中创建一个名为 Global. ...

  7. php仿照asp实现application缓存的代码分享

    php 怎么没有asp 那样的application缓存呢?最近我找了很多,都只有自己写,下面我分享一段代码 class php_cache{ //相对或者绝对目录,末尾不要加 '/' var $ca ...

  8. Capturing ASP.NET Application Startup Exceptions

    It has become common practice to perform tasks during an ASP.NET applications start up process. Thes ...

  9. asp.net Application、 Session、Cookie、ViewState、Cache、Hidden 的区别

    这些对象都是用来保存信息的,包括用户信息,传递值的信息,全局信息等等.他们之间的区别: 1.Application对象 Application用于保存所有用户的公共的数据信息,如果使用Applicat ...

随机推荐

  1. zabbix日常监控NFS(新加一)

    有时候主机使用NFS文件挂载的方式来存储.备份.共享文件:但有时会出现断开的现象. 1.客户机现状 [root@tianxia6 ~]# df -h Filesystem Size Used Avai ...

  2. Hadoop HBase概念学习系列之优秀行键设计(十六)

    我们通过行键访问HBase.尽管使用扫描过滤器可以一次性指明大量的键,但是HBase仅仅能够根据行键识别出一行. 优秀的行键设计可以保证良好的HBase性能. 1.行键存在于HBase中的每一个单元格 ...

  3. Ubuntu 12.04常用快捷键

    ===== 桌面 ===== ALT + F1: 聚焦到桌面左侧任务导航栏,可按上下键导航. ALT + F2: 运行命令 ALT + F4: 关闭窗口 ALT + TAB: 切换程序窗口 ALT + ...

  4. C# 词法分析器(一)词法分析介绍

    系列导航 (一)词法分析介绍 (二)输入缓冲和代码定位 (三)正则表达式 (四)构造 NFA (五)转换 DFA (六)构造词法分析器 (七)总结 虽然文章的标题是词法分析,但首先还是要从编译原理说开 ...

  5. BZOJ 1040 骑士 基环树 树形DP

    题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1040 题目大意: Z国的骑士团是一个很有势力的组织,帮会中汇聚了来自各地的精英.他们劫 ...

  6. python第十四课--排序及自定义函数之自定义函数(案例五)

    演示函数的定义和使用细节: 默认参数:#在设计自定义函数的时候,就存在一个默认值,就算在调用的时候不显示的传入实参,也不会报错.#会用默认值来代替参与后期的运算 def m1(name='张三',ag ...

  7. centos6.2/6.3/6.4+nginx+mysql5.5+php5.3.14

    一.安装所需软件包yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype free ...

  8. Golang包管理工具glide简介

    Golang包管理工具glide简介 前言 Golang是一个十分有趣,简洁而有力的开发语言,用来开发并发/并行程序是一件很愉快的事情.在这里我感受到了其中一些好处: 没有少了许多代码格式风格的争论, ...

  9. C语言不使用加号实现加法运算的几种方法

    今天看到<编码:隐匿在计算机软硬件背后的语言>的第十二章:二进制加法器.讲述了全加器,半加器的原理以及如何实现加法.实现加法时所使用的全加器,半加器中包含的所有逻辑门在C语言中都有相应的运 ...

  10. 关于HTML Button点击自动刷新页面的问题解决

    原因 button,input type=button按钮在IE和w3c,firefox浏览器区别: 1.当在IE浏览器下面时,button标签按钮,input标签type属性为button的按钮是一 ...