The purpose of BeginRequest event processing is to ensure that all shells have been loaded, or reloaded when the extension has changed. void iorchardhost . BeginRequest () { logger.debug ( "beginrequest"); beginrequest (); } protected virtual void beginrequest () { //Ensure all shell contexts is loaded, or need to be reloaded if //extensions have changed monitorextensions ();buildcurrent ();
startupdatedshells (); }Through the analysis of the Iorchardhost.initialize method, the Monitorextensions and Buildcurrent methods are not unfamiliar. Here is the main focus on the Startupdateshells method: void startupdatedshells () { lock (_synclock) { If (_tenantstorestart.any ()) { foreach (var settings in _tenantstorestart.distinct (). ToList ()) {
Activateshell (settings); }_tenantstorestart = Enumerable. empty<shellsettings > (); } } }_tenantstorestart is a collection of shellsettings: Private IEnumerable <shellsettings> _tenantstorestart; The function of this method is to reactivate the shell. In orchard, the concept of a subweb (Tenant) is proposed to increase the site density, which means that an application domain can have multiple subwebs. The shell is a sub-site (Tenant)-level singleton, in other words the shell represents a subweb. This is the way to reactivate the shell when some configuration changes to the orchard, and this change is only for some or some Shell, and there is no need to restart the entire application. As an example of the image point, we sometimes need to restart the operating system after Windows installs or updates the application, while sometimes we just need to restart the application. With respect to the shell, we have a dedicated space to introduce, including what the shell is and what it does, and how to create and activate operational analytics in more detail.Related types:Orchard.Environment.DefaultOrchardHost:IOrchardHost
Orchard Source Analysis (5.2): beginrequest Event Handling (Defaultorchardhost.beginrequest method)