Search code examples
iisiis-7web-configconnection-string

what are all the locations in which connectionStrings can be defined for an iis site?


I'm trying to find all the locations in which a connectionString can be defined for an iis site (to write a script to extract them all). I know it can be part of a web.config. I would like to have a complete list of files it can be configured in. Does it make sense for it to be configured in the site code? Which other configuration files can define a site's connectionStrings?

And a bonus question - how do I know the order of the files in which the connectionString is searched in ?

Thanks,

EDIT:
Additional info - all IIS sites are pure dotnet sites.

Also, specifying the general location of files, rather then file names, is also helpful.
E.g. - connectionStings can be located in external configuration files, whose location is defined at a in an appSettings element in the "%runtime install path%\config\machine.config" file.

Another option is to just link to the relevant docs.
My issue is that I haven't found anything conclusive.


Solution

  • I found a pretty good source for the locations of the IIS dotnet Framework configuration files - https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc754617(v=ws.10)?redirectedfrom=MSDN#inheritance

    You could define additional connectionStrings

    1. In dotnet code.
    2. In env.
    3. In external config files.
    4. For non-IIS scopes - such as user scopes and role scopes.

    These 4 options are not specific to IIS.
    I don't know where options (3) and (4) are defined, and I'm not sure if this list is complete. But by combing this list and the one in the doc, I think we have 99% coverage of defined connectionStrings.