Iis – configure IIS to use the same physical path for different sites but use custom web.config

iisweb.config

First, let me provide you with the outcome I'd like to see.

I unbundle my "application" (pages, code and assemblies) once into a directory.
I use the same application (pages, code and assemblies) to drive multiple sites.
I apply custom application-specific configuration settings for each site.

Problem is currently IIS takes the web.config from the physical directory. If that's the case, all of my applications would share the same basic configuration. I need to change a value that would normally be in the appSettings section of that web.config and make it specific that site.

Any ideas?

Best Answer

You can do this by applying the setting in applicationHost.config and wrapping it in a <location path="sitename"></location> tag.

To see an example, use IIS Manager and disable and enable Windows Authentication (or enable/disable). This will leave a stub location tag for you at the bottom of %windir%\system32\inetsrv\config\applicationHost.config.

Just apply whatever setting you want to that section.

You can also use appcmd.exe or Configuration Editor to add the settings rather than using notepad. Whatever method you prefer.

Related Topic