Sunday, September 25, 2011

Issue: change physical path of site named “Web”

In earlier posts I showed how to use multiple sites within a single WebRole. This required to use the physicalDirectory attribute within the ServiceDefinition file. If you tried to use this attribute you might have run into this issue:

The default site in a WebRole is named “Web”. When you set the physicalDirectory attribute to point to any location – no change will happen.

It seems as if a site named “Web” ignores the physicalDirectory attribute.

But if you change the name to any other name: the physicalDirectory attribute will be used!

For further explanation have a look at the following xml snippets from the .csdef file:

<Site name="Web">
  <Bindings>
    <Binding name="Endpoint1" endpointName="Endpoint1" />
  </Bindings>
</Site>
This will use the default content.
<Site name="Web" physicalDirectory="C:\Code\WebApplication2">
  <Bindings>
    <Binding name="Endpoint1" endpointName="Endpoint1" />
  </Bindings>
</Site>
This will still use the default content.
<Site name="Web1" physicalDirectory="C:\Code\WebApplication2">
  <Bindings>
    <Binding name="Endpoint1" endpointName="Endpoint1" />
  </Bindings>
</Site>
This will use content from WebApplication2.

No comments:

Post a Comment