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,

Source: Windows Questions

LEAVE A COMMENT