Base solution for your next web application
Open Closed

Using ISettingManager during module PreInitialize #1702


User avatar
0
pauldowling created

Hi there, I would like to be able to use ISettingManager during module PreInitialize (specifically, the web module). But I cannot figure out the appropriate way to inject it. Constructor or property injection seem to be out of the question, and I'm not sure how to inject the appropriate dependencies using IIocManager... I'm at an impasse.

Is it possible to use ISettingManager during module PreInitialize? If so, any hints? :)


2 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    You can not use SettingManager in PreInitialize. Because, SettingManager is not registered and initialized in that point. It's usable in PostInitialize. SettingManager is not for startup configuration, it's for runtime configuration. So, to configure modules, use web.config and ConfigurationManager (for ASP.NET Core, use appsettings.json).

    In general, to resolve dependencies using IocManager, see documentation: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Dependency-Injection#DocIocHelper">http://www.aspnetboilerplate.com/Pages/ ... cIocHelper</a> (so, you can just use IocManager.Resolve<YourService>();

  • User Avatar
    0
    pauldowling created

    That was a sufficient hint, thank you! I was able to achieve what I wanted in PostInitialize.