views:

146

answers:

1

I've got a server running Windows Web Server 2008 R2. The machine-level web.config has the following entries:

<location path="Preview">
    <appSettings>
        <add key="Environment" value="Preview" />
    </appSettings>
</location>

<location path="Staging">
    <appSettings>
        <add key="Environment" value="Staging" />
    </appSettings>
</location>

<location path="Production">
    <appSettings>
        <add key="Environment" value="Production" />
    </appSettings>
</location>

I have a website that I'd set up in the direction D:\Sites\Preview\, so the full path would be D:\Sites\Preview\WebSite1. If I put a simple aspx file that just outputs the value of ConfigurationManager.AppSettings["Environment"], it displays the value Preview.

I'm not clear on exactly how that works, but it does. I'd set this up several weeks ago, and just now tried to duplicate this - I put a second site in the D:\Sites\Preview\ directory, expecting that it would automatically pick up the appropriate appSettings entries, but for some reason it hasn't - the same aspx page doesn't show anything.

Additionally, when I go into the IIS manager and open the Configuration Editor, there are no settings in there, whereas there are settings listed for the first site.

Any ideas as to what I could be missing? Is the location element intended to work like this, or did I just find some magical fluke with my first site?


UPDATE:

The actual names of the web sites I've configured are:

  • Preview.Wishinator in D:\Sites\Preview\DanDoes.Wishinator.Site (this is the one that works)
  • Preview.ShowRoom in D:\Sites\Preview\DanDoes.ShowRoom (does not work)
  • Test in D:\Sites\Preview\Test (does not work)
A: 

The location tags above should match the Site Name in IIS to make it match correctly, so my guess is that your site in \Preview\WebSite1 was named in IIS "Preview".

So to summarize the match is not made by folder name but made by the "Site Name" that is configured in IIS.

CarlosAg
Nope - none of the website names were named "Preview", though they both start with "Preview.". The folders containing the sites themselves do not contain the work "Preview" at all.
Daniel Schaffer