I have an asp.net mvc website which of course has a web.config file. I also have an external project which is a class library that uses a .config file for its own app settings. The problem is when I run my web application those external app settings values are not included in the appSettings.
How can I get the external class library projects appSettings values?
You can get the external app setting like that :
var config = ConfigurationManager.OpenExeConfiguration("some.config");
var someKeyValue = config.AppSettings.Settings["someKey"].Value;
You need to either:
1. add those settings to your web.config file.
2. point to the external settings, and use a post build event handler to copy the output into your web project.
<configuration>
<appSettings configSource="my.config" />
</configuration>
Standard convention is that you add the settings to your web.config file. assemblies that are only dlls do not load their own config files. This allows people who use them to specify the settings in their own application.
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