Daniel Mackay
Daniel Mackay

Reputation: 2356

Combining asp.net core and asp.net configuration models

We have a new asp.net core application that is consuming existing .net full framework libraries. In the asp.net core website, we are using the new style of configuration (appsettings.json, environment variables etc). However, in the existing class libraries they are using ConfigurationManager and we would prefer not to change.

We have existing asp.net 4.5 websites built on these libraries and when we deploy to azure we can use application settings & connection strings to override for the correct environment.

Now that we are deploying an asp.net core app that uses these same libraries, the configuration is not working. We have to deploy an app.config along with the connection strings, but for same reason Azure is no longer overriding these per environment.

How can I get these two configuration mechanisms to work together in such a way, that Azure will ultimately override to provide for the correct environment.

(sorry for the long winded question. Any help would be much appreciated)

Upvotes: 0

Views: 126

Answers (1)

binbin.xu
binbin.xu

Reputation: 11

  1. Add System.Configuration.ConfigurationManager from nuget
  2. Add a file app.config:

    <appSettings>
        <add key="webpages:Version" value="2.0.0.0"/>
    </appSettings>
    

Your .NET Core application is a console app ,so it finds app.config first

Upvotes: 1

Related Questions