Web.config in virtual directory is not overriding parent website's Web.config

Lets look at the below example.

we have two application's deployed under IIS, Default Website and ActionURLcode. We have webconfig for both the websites. When you try to run ActionURLCode website, it gives you an error as below.


Connection string is already in the collection


This is due to conflit between webconfig files, A sub web.config doesn't override a parent regardless of application. All web.configs will stack up all the way to the root of the primary application. In order for sub-application folder to make use of a connection string key that is already in use it must first be removed or all connection strings must be cleared. If you want this to be a truly stand alone application as a child add this to your connection strings.


Resolution:

In your webconfig you have to remove or clear the connection strings as below.

<connectionStrings>
    <clear />
    <your connection string>
<connectionStrings>


Comments

Popular posts from this blog

How to Stop Excel from giving a number in scientific notation

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine

System.IO.IsolatedStorage.IsolatedStorageException: Unable to create the store directory