首先,我的主要目的是为我的应用程序动态设置IP和端口。我正在使用IConfiguration注入(inject)一个json配置文件,就像提到的一些教程一样。但是,我无法检索Program.cs中的配置,因为我的WebHostBuilder将同时使用StartUp和Url。因此在主机建立时,我的配置中没有任何内容。WebProtocolSettingssettings_Web=newWebProtocolSettings();varhost=newWebHostBuilder().UseIISIntegration().UseKestrel().UseContentRoot(Direc
首先,我的主要目的是为我的应用程序动态设置IP和端口。我正在使用IConfiguration注入(inject)一个json配置文件,就像提到的一些教程一样。但是,我无法检索Program.cs中的配置,因为我的WebHostBuilder将同时使用StartUp和Url。因此在主机建立时,我的配置中没有任何内容。WebProtocolSettingssettings_Web=newWebProtocolSettings();varhost=newWebHostBuilder().UseIISIntegration().UseKestrel().UseContentRoot(Direc