1

I have a Web API project, that has 3 controller projects eg:

ControllerProject1

ControllerProject2

ControllerProject3

The hierarchy is as follows:

ControllerProject3 and ControllerProject2 cannot access each other but can both access ControllerProject1

each project has its own Web.config.

I then add a setting to the config of ControllerProject1 as follows:

<add key="SettingName" value="SettingValue"/>   

In ControllerProject1 I obtain values from the Web.Config as follows:

var setting = ConfigurationManager.AppSettings["SettingName"];

However, my issue is that I now want to obtain the value from ControllerProject1 Web.Config, through a method contained in ControllerProject2 or ControllerProject3

I know I can add settings to all 3 configs, but my question is, is it possible to do this, and if so how can I do this?

EDIT:

This question Accessing Web.config from another Project does this by declaring the path to this file, but I would prefer to do this by referencing the project rather than the path to the config file

Alex
  • 3,730
  • 9
  • 43
  • 94
  • 1
    You can use a static class in the project that has the web.config file and expose the value of the web.config in an internal property – too_cool Jan 29 '18 at 10:07

0 Answers0