1

I am running a test rig with IIS6 serving an ASP.NET (and Sharepoint) web site. We have several clients, and so we have custom root Web.config files for each client.

For this test rig, I want to just serve straight from the Trunk of our source control. However, I'd like to be able to select different root Web.config files based on the URL (or port or whatever) I use to access the site, so I can just use one checkout of the source and run all the sites with their appropriate settings.

Is this possible?

  • Are you just talking about settings that would be in appSettings (or a custom config section), or other things as well? – MattB Feb 17 '10 at 16:25
  • Other things as well, preferably. If that makes it impossible, I might be able to make do with a restricted subset. – Scott Stafford Feb 17 '10 at 17:59
  • @Scott Stafford: Sorry, I thought I had a solution that might be workable for you, but once I thought about it for a few minutes realized it wouldn't work. – MattB Feb 17 '10 at 21:27
  • @MattB: Thanks anyway. I am surprised this isn't a common use case, maybe there's some other way to get the effect I want? – Scott Stafford Feb 17 '10 at 22:46
  • @Scott Stafford: just FYI the path I was going down was to change the web.config file at runtime based on the URL. That probably doesn't work though if you want to test multiple sites at the same time. – MattB Feb 18 '10 at 00:55
  • How would you do that? – Scott Stafford Feb 18 '10 at 15:03
  • @ScottStafford Did you eventually find a way to implement this? I'd also love to configure my local IIS to use different web.config depending on the url, so I can debug my local site in multiple environments without constantly updating the web.config manually. – T_D Jan 19 '17 at 14:34

1 Answers1

2

ASP.NET uses a heirarchy to determine which web.config file gets used. There is a machine.config with global system values, then each website has a web.config in it's root, and each virtual directory uses it's own web.config files. We run multiple asp.net applications on the same server using a combination of multiple websites setup in IIS and many virtual directories on each website. Each virtual directory runs in it's own appdomain and acts as an isolated application. If you want to setup multiple websites on a single IP address you can use host headers to have each web site respond to a different URL request.

Greg Bray
  • 5,610
  • 5
  • 36
  • 53