0

As I understand it, it is possible to add connection strings and other configuration objects to a site's scope in the following files -

  1. machine.config
  2. applicationhost.config
  3. the site's web.config

I am running the following command -
APPCMD set config "site1" /section:ConnectionStrings /+"[ConnectionString='Data Source=localhost;Integrated Security=SSPI;', Name='Northwind', providerName='System.Data.SqlClient']"

This adds a element to the web.config file.
I want to see it in the applicationHost.config file.

I tried to add it manually under the <site> element -

        <site name=...
             <connectionStrings>
                 <add connectionString="Data Source=localhost;Integrated Security=SSPI;" name="fromApplicatinoHost" providerName="System.Data.SqlClient " />
             </connectionStrings>
        </site>

But this is not legal syntax for the applicationHost.
So how can I add the connectionString to the applicationHost ?

Thanks,

Nimrod Fiat
  • 473
  • 3
  • 12
  • ADO.NET connection strings should go to root web.config or the site's web.config. applicationHost.config is not an option. – Lex Li Jul 28 '21 at 14:30
  • Lex do you have a link to a relevant doc ? Thanks ! (btw I have a VM in which some connection strings are in the machine.config) – Nimrod Fiat Jul 28 '21 at 19:38
  • You can get information in this [doc](https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/connection-strings-and-configuration-files). It lists all possible ways and configuration files to store connection strings. Machine.config, web.config, app.config, but no applicationhost.config. – Bruce Zhang Jul 29 '21 at 07:53

1 Answers1

0

you can do it with the /commit argument. E.g.
appcmd set config "ping" /section:system.webServer/security/authorization /+"[accessType='Allow',roles='administrators']" /commit:apphost
Writes the authorization to the applicationhost.

The default when changing a site context is to write to the site's web.config. Adding /commit:machine writes to the machine.config.

A complete answer would have the complete set of config files, mapped to the appcmd name for the file, but this also answers my question.

Nimrod Fiat
  • 473
  • 3
  • 12