Application Lifecycle

Dynamicweb has a lifecycle within the IIS, which this document will outline. The headings for these overall lifecycle states are the following:

  1. Application_Start
  2. Application_BeginRequest
    1. Ensure Dynamicweb is started
  3. Application_OnPreRequestHandlerExecute
  4. Application_EndRequest
  5. Application_Error
  6. Application_End

The naming is purposely similar to the ASP.NET Application Life Cycle Overview for IIS 7.0 (https://msdn.microsoft.com/en-us/library/bb470252.aspx). The formatting is present to illustrate when a state has a corresponding end-state.

Of the above states, 01 to 04 are of particular interest, as they expose notifications such as BeforeDynamicwebStart which you can hook into in your custom code.

This event fires once every time the application is started, resulting in the following:

  • Notification Manager is initialized
  • BeforeStart notification fires
    • MVC is initialized (Rank = -80)
  • AfterStart notification fires
  • ExecutionTable initalized (Rank = -50)

This event fires once for every request to a frontend or backend page, resulting in the following:

  • BeforeBeginRequest notification fires
    • Ensures Dynamicweb.Context is available (Rank = -100)
  • Timestamp request (e.g. used for debug-information)
  • Ensure Dynamicweb is started
  • AfterBeginRequest notification fires

Ensure Dynamicweb is started checks to see if Dynamicweb is initialized. If it isn’t, the following happens:

This event is guaranteed to only execute if AfterDynamicwebStart has not been fired.

  • BeforeDynamicwebStart notification fires
    • Ensures Dynamicweb.Context is available with request (Rank = -100)
  • Examine database and global settings
  • Redirect to setup wizard if needed
  • Setup TaskManager
  • Setup Log
  • Check/setup license
  • Run update scripts
  • Setup MEF and Scheduled Tasks
  • Initialize Modules
  • Initialize ItemManager
  • AfterDynamicwebStart notification fires

This event handles user authentication/login.

  • BeforePreRequestHandlerExecute notification fires
    • Ensures Dynamicweb.Context is available with session (Rank = -100)
  • User is authenticated
  • AfterPreRequestHandlerExecute notification fires

  • Write dbstat if requested
  • Write debug information if requested
  • Write dbcount if requested

Cleanup and present an error message, depending upon what is possible.

No custom code.