我有asp net webapi,我需要解决启动文件中的一些选项。这里的选项有一个简单的类,它从 json 配置中获取参数。在启动时注册 optionsAutofacModule where register configuration section 我需要什么。示例:RegisterConfigurationOptions<IdentitySettings>(builder, configuration.GetSection("Identity"));
在 OptionAutofacModule 中,使用containerBuilder.RegisterModule<OptionsAutofacModule>();
在启动 .cs 中调用的 . 所以,我需要访问startup.cs中方法内的“identitysettings”。
编辑 0:我有 net core 项目和经典的 asp net web api。Net core 项目使用配置,从 json 文件解析什么。我可以使用 IOptions 在控制器经典 .net webapi 项目中访问此配置。但我无法在 startup.cs 中访问此选项