Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 646277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:35:38+00:00 2026-05-13T21:35:38+00:00

I have a solution which has multiple output projects (a website, and admin tool,

  • 0

I have a solution which has multiple output projects (a website, and admin tool, and a SOAP API layer).

They each share common projects in the solution (the service layer, data layer etc). In one of these common projects, I am looking to store a config layer.

Right now, we have three seperate appsettings config files for each output project –

  • development.AppSettings.config
  • testing.AppSettings.config
  • production.AppSettings.config

So altogether, there are nine config files. Only one is used in each project, as they are referenced by utilising the configSource attribute in the web.config appsettings node.

Anyhoo, it’s getting to be a pain any time we want to add/remove values from our config files, because it means that we have to change all nine files to do this. And here’s what I’d like to do:

In the common project, we have three config files as above. These would be set to copy to the output directory, so that each project has a copy of them. These would be the ‘base’ config.

Then in each project, I would like to have three files again, but they wouldn’t necessarily have to contain the same values as the base configs. If they did however, then the base config value would be overridden by the value in the output project config. A form of configuration inheritance, I suppose.

On application start, I’d like to be able to get these two config files – the base config, and the project config file. And then set the app settings accordingly.

What I’m wondering though, is what’s a nice way of determining which file to use? Also, I’m wondering if this is a good way of sharing application values across a large solution, and if there’s another, perhaps more efficient way of doing it?

If I’m in development mode, then I don’t want production.appsettings.config, and vice versa if I’m in production mode.

Is there a simple way to get the mode (development/testing/production) that I’m in before I go off and get the configurations?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:35:39+00:00Added an answer on May 13, 2026 at 9:35 pm

    After some careful thought, and a trip to the toilet at 03:30, I came across a solution which works.

    Let’s say that we have some appSettings in our base config file:

    <add key="MyKey1" value="MyValue1" />
    <add key="MyKey2" value="MyValue2" />
    <!-- And so on... -->
    <add key="MyKey5" value="MyValue5" />
    

    And in my output project, I have three appSettings:

    <!-- This is used to identify which config to use. -->
    <add key="Config" value="Development" />
    
    <!-- Different value to the one in the base -->
    <add key="MyKey2" value="NewValue2" />
    
    <!-- This key does not exist in the base config -->
    <add key="MyKey6" value="MyValue6" />
    

    In my Application_Start, I have a call to GetConfigs():

    ConfigHelper.GetConfig(HostingEnvironment.MapPath(“~/bin/BaseConfig”));

    And the actual GetConfigs function:

    public static void GetConfigs()
    {
      if (configMode == null)
      {
        configMode = ConfigurationManager.AppSettings.Get("Config").ToLowerInvariant();
      }
    
      //Now load the app settings file and retrieve all the config values.
      var config = XElement.Load(@"{0}\AppSettings.{1}.config".FormatWith(directory, configMode))
        .Elements("add")
        .Select(x => new { Key = x.Attribute("key").Value, Value = x.Attribute("value").Value })
        //If the current application instance does not contain this key in the config, then add it.
        //This way, we create a form of configuration inheritance.
        .Where(x => ConfigurationManager.AppSettings.Get(x.Key) == null);
    
      foreach (var configSetting in config)
      {
          ConfigurationManager.AppSettings.Set(configSetting.Key, configSetting.Value);
      }
    }
    

    Now, my output project effectively has the following configuration settings:

    <add key="Config" value="Development" />
    <add key="MyKey1" value="MyValue1" />
    <add key="MyKey2" value="NewValue2" />
    <!-- And so on... -->
    <add key="MyKey5" value="MyValue5" />
    <add key="MyKey6" value="MyValue6" />
    

    Simples!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a solution in Visual Studio 2008 which has multiple projects. One of
I have a solution which has many projects inside it. I build the solution
I have a large solution which has multiple apps which all share some common
I have a page that displays multiple Formsets, each of which has a prefix.
I have an ntier solution which has a Domain project for my POCO classes.
I have a solution which contains six projects. Four of the projects are class
I have a VS2005 solution which contains a variety of projects (C++ DLLs, C++
I have a scanned image of a document which has multiple boxes which may
I am looking best solution in PHP for a search form which has multiple
We have a solution with multiple web projects, and there are some pages that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.