5

I am building a Web API in .NET core 1.1. Since .NET core doesn't support web.config, I have moved all the configuration to appSettings.json.

On production web server we have other ASP.NET applications (with target framework 4.5.1) running that uses connection string from machine.config. I fear that the IT team would not permit me to have connection string in appSettings.json because they would now have to maintain it at multiple places.

Is it possible to read connection string from machine.config in .NET core?

user2107373
  • 427
  • 3
  • 16
  • 3
    `machine.config` is only an XML file when all is said and done, so as long as you can [find it](https://stackoverflow.com/questions/2325473/where-is-machine-config), you can parse it. Note that you cannot use `RuntimeEnvironment.SystemConfigurationFile`, since that's not supported on .NET Core. Rather than writing code for this, you may just want to make the location of `machine.config` a (one time) configuration setting. Then read the connection string from there. Even if you do that, make sure you can override it with a local setting, because that's just common sense. – Jeroen Mostert Jun 08 '17 at 12:30

0 Answers0