Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does web.config override any app.configs?

If I have a web application (with its own web.config) and a .dll it uses happens to have its own app.config which settings file wins when there is a conflict?

like image 658
Kirschstein Avatar asked Mar 01 '23 07:03

Kirschstein


2 Answers

No, you will not have any conflict because a .dll cannot have its own .config file.

Even if you put a .config file for your library in the same folder, the application is simply not going to pick up the values from it.

If you wish to use some of those values, you can merge them into your web.config.

like image 194
Mark Seemann Avatar answered Mar 12 '23 22:03

Mark Seemann


You can merge settings from another configuration file into your web.config file. This also allows you to override values aswell if they have the same key.

web.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings file="YourSettings.config">
    <add key="KeyToOverride" value="Original" />
    <add key="KeyToNotOverride" value="Standard" />
  </appSettings>
  ...

YourSettings.config

<appSettings>
  <add key="KeyToOverride" value="Overridden" />
  <add key="KeyToBeAdded" value="EntirelyNew" />
</appSettings>
like image 23
James Avatar answered Mar 13 '23 00:03

James