Problems with ASP.NET, machine-level web.config, and the location element

Posted by Daniel Schaffer on Stack Overflow See other posts from Stack Overflow or by Daniel Schaffer
Published on 2010-04-15T00:22:54Z Indexed on 2010/04/15 4:43 UTC
Read the original article Hit count: 293

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about iis7

Related posts about web.config