In an effort to try and take the pointy-clickyness out of configuring IIS for our application, I've been looking at appcmd. Specifically it's ability to export config trees and reapply them with minimum fuss.
Generally, this gives the exported configuration:
appcmd list Config /section:httpProtocol /config /xml > template.xml
which I can then reimport at a later date with:
appcmd set Config /in < template.xml
and the changes get applied. This works well for everything other than custom error pages.
I've exported these with:
appcmd list Config "Default Web Site/intranet" /section:httpErrors /config /xml > customerrors.xml
but when I try and import with:
appcmd set Config /in < customerrors.xml
I get the following error:
ERROR ( hresult:8007000d, message:The input contained an error element, which may indicate that the operation producing the input has failed. )
Well yes, that's because I'm importing errohandler entries that look like this:
<?xml version="1.0" encoding="UTF-8"?> <appcmd> <CONFIG CONFIG.SECTION="system.webServer/httpErrors" path="MACHINE/WEBROOT/APPHOST/Default Web Site/intranet" overrideMode="Inherit" locked="false"> <system.webServer-httpErrors errorMode="Custom"> <error statusCode="500" prefixLanguageFilePath="" path="/intranet/ErrorPages/500-100.asp" responseMode="ExecuteURL" /> <error statusCode="500" subStatusCode="100" path="/intranet/ErrorPages/500-100.asp" responseMode="ExecuteURL" /> </system.webServer-httpErrors> </CONFIG> </appcmd>
...which is what
appcmd gave me (which would imply that the 'error' element really is what is required). Is this a case of appcmd trying to be too clever, or am I missing something ridiculously obvious?