In IIS I want directory listing to be enabled when served from the test server. With the same web.config
I don't want directory listing to be enabled on the production server. Is this possible?
The same entire directory structure is mounted on both test and production servers.
My current web.config
looks like:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path=".">
<system.webServer>
<directoryBrowse enabled="false" />
</system.webServer>
</location>
<location path="this/directory/listing/should/only-show-on-test-server">
<directoryBrowse enabled="true" />
</system.webServer>
</location>
You have two options:
Your main web.config would have:
the second file
ServerSpecificDirectorySettings.config
has just:location
nodes in the ApplicationHost.config file.Both solutions have pros and cons, I guess it depends a bit on how you deploy your sites. If you want to keep all the files exactly the same on every server you have to go with the second option. But for an x-copy deployment the first option is better.