Why is Web.config looking for configSource in the project folder instead of bin?

I defined my configSource to search for configuration files in the config subdirectory, as follows:

<connectionStrings configSource="config\ConnectionStrings.config" /> 

I have a configuration file defined as a linked file, so when the build happens, it just gets copied to my bin \ config folder.

However, my web application projects are looking at the configuration folder of the development project, not the bin \ config folder. I confirmed this using Process Monitor.

So, I have a few questions:

  • Why is he looking there instead of bin \ config - did I miss the path of the relative path somewhere?
  • Linked files are not copied there, but only in bin. I understand that this is the correct behavior. Is this the correct assumption or should it be copied to both locations? If so, what is the setting to enable this?
  • Is it good to use a subfolder for linked files or leave it in the root of the project?

Thanks a lot!

UPDATE: I use the method described here: http://consultingblogs.emc.com/jamesdawson/archive/2008/06/03/using-linked-files-with-web-application-projects.aspx to copy the configuration files, and experimenting a bit, I answered question No. 2. No, this is not the default behavior in Visual Studio, but this work ensures that the files will be copied to both locations.

+6
source share
1 answer

I believe this may help you a little. How to use multiple Web.config files

Basically, you can have as many configuration files as you want if they are located in a separate folder of your web application. I'm a little confused by the part of your comment that mentions โ€œanother web projectโ€, can you be more specific in this section? Also, I found much more details about this on msdn , I suggest you check it out.

Happy coding!

+1
source

Source: https://habr.com/ru/post/922604/


All Articles