Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have defined my configSource to look for config files in a sub-directory called config, as follows:

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

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

However, my web app projects are looking at the development project config folder instead of the deployment bin\config folder. I confirmed this with Process Monitor.

So I have several questions:

  1. Why is it looking there instead of bin\config - did I miss a relative path setting somewhere?
  2. The linked files are not copied there but to bin only. My understanding is that this is the proper behavior. Is that a correct assumption or should it be copied to both locations? If so, what is the setting to enable that?
  3. Is it good practice to use a sub-folder for linked files or should I leave them in the project root?

Thanks much!

UPDATE: I am using the method described here: http://consultingblogs.emc.com/jamesdawson/archive/2008/06/03/using-linked-files-with-web-application-projects.aspx to ensure that the config files are copied, and doing a little experimentation I have answered question #2. No it is not default behavior in Visual Studio but this work-around ensures the files are copied to both locations.

like image 368
Shane K Avatar asked Aug 10 '12 18:08

Shane K


People also ask

Where are web config files located?

The Web. Config file is used to configure Oracle Web Application functionality. This file is typically installed in the c:\Inetput\wwwroot\WebApp directory.

What is Web config in views folder?

The web. config file in the views folder is to do some specialized settings you want to apply to pages inside the view folder. Like config settings like: connection string / appsettings etc. but that will be applicable to only that folder and rest of the project will pick up the settings from web.

Where do I put appSettings in web config?

Locate the web. config file in the root directory of your application (or create one if it does not already exist). Add an <appSettings> element. Add <add> child elements along with key / value pairs to the <appSettings> element as required.

What is web config file Why do we use web config file?

A web. config file is a Windows file that lets you customize the way your site or a specific directory on your site behaves. For example, if you place a web. config file in your root directory, it will affect your entire site (www.coolexample.com).


1 Answers

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

Basically you can have as many config files as you like, as long as they are in separated folder of your web application. I a bit confused by part of your comment where you mention "different web project", could you be a bit more specific in that department? Also, I have found far more detail about this on msdn, I suggest you check it out.

Happy coding!

like image 156
Мitke Avatar answered Sep 30 '22 12:09

Мitke