8

I am creating a test version of an existing production site. A virtual web service application exists inside the site - and the two web configs have the same connection string.

There are no "clear" tags in the production web configs and the site and the web service co-exist merrily on two separate app pools.

On the test site however, every time I browse to the webservice URL I receive the Configuration Error "The entry 'ConnectionString' has already been added."

The test site and corresponding virtual application use their own separate app pools. Any ideas?

Thanks Jim

Spodgy
  • 302
  • 5
  • 13

2 Answers2

19

Web.config inheritance happens even between different appPools. If you want to stop this behavior, you should add the attribute enableConfigurationOverride="false" to your appPool in the applicationHost.config file (located in %WINDIR%\System32\inetsrv\Config and %WINDIR%\SysWOW64\inetsrv\config) as in the following example:

<add name="MyAppPool" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" enableConfigurationOverride="false">
    <processModel identityType="NetworkService" />
</add>

Matteo

Matteo Sganzetta
  • 768
  • 7
  • 20
2

I think the problem is related that they are one site inside the other. Like a Website with a Virtual Directory inside.

In this case... the Virtual Directory web.config is "inheriting" the parent web.config

Here you can see details of how to solve this: How to stop inheritance of <configSections>in Web.Config

Other options: https://stackoverflow.com/a/367372/7720

If the problem is in other parts of your web.config (not in the sections) you can just wrap the conflicting part with <location path="." inheritInChildApplications="false">.

Other option could be let the webservice grab the connection from the website.

Community
  • 1
  • 1
Romias
  • 13,783
  • 7
  • 56
  • 85
  • Thanks - but does this apply if the virtual application is running in a different app pool? (Configured at the folder level of IIS) – Spodgy Apr 29 '14 at 15:20
  • Not really sure... In my case, I THINK I HAVE different App Pools in parent and child, but as it is shared hosting not easy way to know. – Romias Apr 29 '14 at 16:09
  • OK.. Thanks. I've opted for changing the connection string. – Spodgy Apr 29 '14 at 16:11