0
votes

There are 2 applications pointing to 2 different paths. 1. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config 2. C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config

I want to keep my connection strings in 1 single file so that both the applications should be able to read the same.

Any idea?

1
How about not storing your application configuration in the framework installation directory? The configurations there are basic configurations for all applications. Don't write application-specific configuration values in there. Put a web.config in your application root. - CodeCaster
We have multiple applications, and all applications have same connectionstring. Any suggestion. Few in classic asp and few in .net - student
Edited the same. Can anyone answer this? - student

1 Answers

0
votes

You can try to store your connection strings in external .config file and include it in both web.config files. Here is how to export profile configuration into a dedicated configuration file. This is web.config:

...
  <system.web>
    ...
    <profile configSource="profile.config" />
    ...
  </system.web>
...

This is profile.config:

<profile>
  <properties>
    <add name="Name" type="String" />
    <add name="Age" type="Int32" />
  </properties>
</profile>

Make sure you use .config as the extension of your files so they cannot be served to the browser.

See this blog post for details

To use one .config file in multiple applications create a symbolic link to that file in each application folder and reference that link in web config. Use mklink command in elevated command prompt:

cd "c:\YourApplicationDirectoryWhereWebConfigIs"
mklink profile.config "c:\YourSharedConfigFilesDirectory\profile.config"