psj01
psj01

Reputation: 3245

Where to find the location of IIS manager connection strings

I was getting an error saying that one of my connection string in my application's web.config file was already defined.

I checked in the IIS settings and when I checked the connection string property it was there already with Entry Type : Inherited.

So I went up the chain and went all the way up to the root of the localhost and checked the connection strings there.

I found a bunch of connection strings there as well.. but they're also all with Entry Type Inherited..

I checked the web.config file inside the wwwroot folder but didn't find any connection strings defined in there..

Where could these connection strings be coming from?...

enter image description here

Upvotes: 4

Views: 7124

Answers (1)

CodeCaster
CodeCaster

Reputation: 151604

Configuration files in .NET are inherited in the following order:

  • systemroot\Microsoft .NET\Framework\versionNumber\CONFIG\Machine.config
  • systemroot\Microsoft .NET\Framework\versionNumber\CONFIG\Web.config (ASP.NET only)
  • (application directory)\Web.config

So the connection strings that show up as "inherited" are specified in either of the upper two files.

Reference: MSDN: ASP.NET Configuration File Hierarchy and Inheritance

If you don't want to alter the machine-wide configuration, you can <clear /> them from being inherited in your application's configuration as explained in What does <clear /> signify when specifying a connectionstring?:

<connectionStrings>
   <clear />
   <add name="LocalSqlServer" connectionString="..." /> 
</connectionStrings>

Upvotes: 6

Related Questions