Forum Discussion
David Levine
Aug 27, 2019Brass Contributor
Manage IIS Settings via ApplicationHost.Config vs. Web.Config
I have an IIS setup where multiple websites exist that all share the same document root. Each of the websites have a specific default document though. This has been managed in the past by manually ...
- Aug 27, 2019
Dave Patrick
Aug 27, 2019MVP
Looks like you can use the /AppHostConfig switch
https://docs.microsoft.com/en-us/iis/extensions/introduction-to-iis-express/iis-80-express-readme
- David LevineAug 27, 2019Brass Contributor
Thanks for the reply Dave;
So, I am looking at the following:
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/jj635852(v=ws.11)
and
https://docs.microsoft.com/en-us/iis/configuration/system.webserver/defaultdocument/It seems the syntax I want to specifically write the config to applicationHost.config is /COMMIT:APPHOST but I cant seem to figure out the rest of the syntax... keep getting errors:
PS C:\Windows\system32\inetsrv> .\appcmd.exe set config "testsite2" /section:defaultDocument /enabled:true /+files.[value='site2-home.html'] /commit:APPHOST ERROR ( message:Malformed collection indexer; format is [@position,name='value',name2='value2',...]. The @position specifier is optional, and be '@start', '@end', or '@N' where N is a numeric index i nto the collection. ) PS C:\Windows\system32\inetsrv>
- Dave PatrickAug 27, 2019MVP
- David LevineAug 28, 2019Brass Contributor
Yep - that did it...
PS C:\Windows\system32\inetsrv> .\appcmd.exe set config "testsite2" /section:defaultDocument /enabled:true "/+files.[value='site2-home.html']" /commit:APPHOST Applied configuration changes to section "system.webServer/defaultDocument" for "MACHINE/WEBROOT/APPHOST/testsite2" at configuration commit path "MACHINE/WEBROOT/APPHOST"
Thank you so much!!