Try our conversational search powered by Generative AI!

How can register service in the startup.cs ? Optimizely CMS 12 & .Netcore 6.0

Vote:
 

Hi Team,

I have implemented one of the settings service as below

public class SettingsService : ISettingsService

{

}

and register the above service in startup.cs like below
 public void ConfigureServices(IServiceCollection services)
 {

            services.AddSingleton<ISettingsService,SettingsService>();

            services.AddTransient<ISettingsService,SettingsService>();
}

but it's not calling "SettingsService". could you please help us how can we call the "SettingsService" in Optimizely CMS 12 & .netcore 6.0

#319944
Apr 03, 2024 17:39
Vote:
 

Hi Kumar

You have already registered your service successfully. How do you know it is not calling? Did you inject ISettingService into anywhere in your code? 

p.s. In your above example, you have registered the same SettingService twice with different lifecycles , this would cause a lot of confusion, and I suggest you choose only one. 

#319981
Apr 03, 2024 23:14
Vote:
 

It seems you created three threads of same topic. I deleted one but two have answer(s) so I will leave them be. the other thread is How to register service in the startup.cs file. | Optimizely Deve

#319986
Apr 04, 2024 7:07
* 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.