aspnet / MicrosoftConfigurationBuilders

Microsoft.Configuration.Builders
MIT License
118 stars 61 forks source link

Environment variable is always empty - Using EnvironmentConfigBuilder - WORKED #223

Closed TejendraPrasad closed 1 year ago

TejendraPrasad commented 1 year ago

Hi,

I have aspx web form .net 4.8 application

Web.Config

<configSections> <section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" /> </configSections> <configBuilders> <builders> <add name="Environment" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </builders> </configBuilders>

<appSettings configBuilders="Environment"> **<add key="AppSettings_AppPassword" value="Driven from Environment Variable"/>** <!--Azure AD Config--> <add key="ida:ClientId" value="" /> <add key="ida:AADInstance" value="" /> `

in default.aspx.cs

Also value gets printed when logging all

foreach (var key in ConfigurationManager.AppSettings.AllKeys) {

               `    Log.Information("ConfigurationManager " + key + ":   " + WebConfigurationManager.AppSettings[key]);`
              `  }`

Only when trying by individual key its null.. - it got fixed it was due to mismatch of Nuget package version..

Thank you! Tej

TejendraPrasad commented 1 year ago

Working have changed the above code to working code..

Thank you!