3

I have an issue where I've set up a connection string at the Machine level in IIS, and it is inherited all the way down as expected... EXCEPT for the application I want to use the string in. Other applications at the same level do inherit the string.

The application in the past had the connection string with the same name defined. Removing it at the application level removes it permanently: it will not be inherited. Adding it at the application level makes it local. I can't find a way for that application to inherit the connection string.

Is there some way to reset this behavior? Short of removing the application entirely?

TastyPorkChop
  • 33
  • 1
  • 3

2 Answers2

3

I just had this same problem.

I had a connection string defined for the server node (in IIS), then clicked on Connection Strings on an application node under the default web site. I altered that, then decided that the alterations weren't needed so deleted the connection string from the application node.

This is what happened. The connection string was actually defined for the server, and inherited by the application node, therefore I wasn't actually deleting it from the application node, what I was actually saying was, "I don't want this application to inherit this connection string".

I've deleted it so may not have the config exactly right but IIS implemented this by adding something like the following into web.config for the application:

<connectionstrings>
    <remove name="connstringname"... />
</connectionstrings>

So, the fix is to edit web.config and remove that entry, your application will then be able to inherit the connection string from the higher node.

Falcon Momot
  • 24,975
  • 13
  • 61
  • 92
Beau
  • 31
  • 2
1

Open the AppHost configuration at C:\Windows\System32\inetsrv\config\applicationHost.config and search for the name of your app, review the matches, do any of them have to do with connectionstrings?

Does your app has a parent that may remove the connection string in question?

Peter Hahndorf
  • 13,763
  • 3
  • 37
  • 58
  • I did this. None of the app matches had any mention of connection strings. After a bit of playing round I found out changing the App Pool allowed the application to inherit the connection string. I'm not sure why that would be. – TastyPorkChop May 04 '12 at 19:54
  • If the App Pool was configured to use a different version of .NET from the others, that might be the cause. There is a machine.config for each version of the framework. – Chris McKeown May 04 '12 at 21:49
  • @ChrisMcKeown Ah! After a long bit of work it turns out it was the .NET version of the App Pool config. More specifically: the .NET version at the machine level in IIS manager was defaulting to v2.0 and the app had a pool set to v4.0. Right clicking in the features view choosing "Change .NET Framework Version", switching to v4.0 and setting the connection string there had the proper effect. – TastyPorkChop May 15 '12 at 14:56