Nimrod Fiat
Nimrod Fiat

Reputation: 483

tell appcmd to write configuration to the applicationhost.config rather then the site's web.config

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,

Upvotes: 0

Views: 672

Answers (1)

Nimrod Fiat
Nimrod Fiat

Reputation: 483

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.

Upvotes: 0

Related Questions