Try our conversational search powered by Generative AI!

When does the UNinitialize method in an InitializationModule get called in an applications lifecycle?


The Dev Guide for CMS 12 says this regarding Initializing the CMS (here):

Custom initialization logic can preferably be done through standard ASP.NET 
Core components like for example IStartupFilter or  IHostedService. The
IInitializable system (described below) within CMS that was built for
ASP.NET - where there was no central Startup class - is also available in
ASP.NET Core application and can be used also.

Has anyone successfully converted an InitializationModule with events into standard .NET Core components? I found an add-on where the Initialize() method is called during Startup/Configure() but it doesn't use an Uninitialize() method. IHostedService only has StartAsync and StopAsync which might* be comparable to Initialize() and Uninitialize(). (*I'm still learning about IHostedService.) 

I have a couple of questions then:

  1. Where in the application's startup pipeline is Optimizely's InitializableModule called to set and call Initialize() and then Uninitialize()?
  2. Is IHostedService.StartAsync/StopAsync the same as Initialize() and Uninitialize()? If so, I can follow the instructions in the link behind IHostedService above.
  3. Also, if it's the same, do I call it in Startup/ConfigureServices() or Startup/Configure() in Startup.cs or somewhere else?

Questions 1 & 3 could be answered if there's a diagram of the startup pipeline for CMS 12.

Thank you!!

Edited, Nov 15, 2023 23:06

Hate to answer my own question, but I figured out today that I was searching for Uninitialize when I should have been searching for IHostedServices.

There are a couple of examples others have posted in the forums, like Henrik's example here.

And Minesh's example here:

Nov 16, 2023 23:22
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.