How to access external .config files?

I have an asp.net mvc site which of course has a web.config file. I also have an external project, which is a class library that uses the .config file for its own application settings. The problem is that when I launch my web application, these parameter values ​​of the external application are not included in the appSettings.

How can I get appSettings values ​​for external class library objects?

+3
source share
2 answers

You need to either:
 1. Add these settings to the web.config file.
 2. Specify external settings and use the post build event handler to copy the output to your web project.

<configuration>
    <appSettings configSource="my.config" />
</configuration>

, web.config. , dll, . , , .

+2

:

    var config = ConfigurationManager.OpenExeConfiguration("some.config");
    var someKeyValue = config.AppSettings.Settings["someKey"].Value;
+6

All Articles