I'm porting an app from .Net Framework to .Net Core and try to use ConfigurationManager from System.Configuration.ConfigurationManager package to get a connection string from Web.config. The problem is that it only contains default connection string from machine.config. I know that ASP.Net Core use appsettings.json with IConfiguration as a default way to manage configuration but as I understand System.Configuration.ConfigurationManager package was added to simplify the migration. So that's the right way to use ConfigurationManager to get the data from Web.config instead of global machine.config?
Web.config content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="My" connectionString="sample data" />
</connectionStrings>
</configuration>
Looks like the file must be named App.config, even if it's web app. After renaming Web.config to App.config it's read properly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With