4

In my solution, I have 2 projects, call them Foo and Bar. When deployed, Foo is the root site (http://mycompany.com) and Bar is a sub-directory (http://mycompany.com/sub).

When I work on them locally in IIS Express on my local machine, I need to replicate things into web.config of both projects since I work on them separately. For example, I have one of the HMTL5 Boilerplate rules for "cache busting" in my Rewrite rules:

<rewrite>
    <rules>
        <rule name="Cachebusting">
            <match url="^(.+)\.\d+(\.(js|css|png|jpg|gif)$)" />
              <action type="Rewrite" url="{R:1}{R:2}" />
        </rule>
    </rules>
</rewrite>

If I just leave it in the web.config for Foo, then when I work on Bar, it's not applied and I get errors since the rewrite isn't happening. So I've replicated sections into the web.config for both projects.

But when I publish the solution to Azure, I get conflicts because of the inheritance rules since the web.config for Foo is in the root.

What is the best way to manage this? I tried to search on this topic but couldn't find this exact problem described.

Update:

My applicationhost.config for IIS Express is as such:

        <site name="Bar" id="3">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="E:\Code\mycompany\Bar\Bar" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:65052:localhost" />
            </bindings>
        </site>
        <site name="Foo" id="4">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="E:\Code\mycompany\foo" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:50477:localhost" />
            </bindings>
        </site>

I tried editing it to make both apps part of the same site, with these changes but no luck. Seems to have broken everything :)

        <site name="Foo" id="3">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="E:\Code\mycompany\foo" />
            </application>
            <application path="/Sub" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="E:\Code\mycompany\Bar\Bar" />
            </application>              
            <bindings>
                <binding protocol="http" bindingInformation="*:65052:localhost" />
            </bindings>
        </site>
TMC
  • 8,088
  • 12
  • 53
  • 72
  • Can both sites not share the same linked configuration file? – Kane Jun 26 '12 at 04:42
  • They can't share the same web.config file since the sub-site has settings in it that don't apply to the parent site (like connecetion strings) – TMC Jun 27 '12 at 03:16

2 Answers2

0

Make your root site (http://mycompany.com) as a website in IIS, and your sub-directory as virtual directory in IIS.

IIS shares the Rules defined in root website ('s web.config) with the virtual directory.

Waqas Raja
  • 10,802
  • 4
  • 33
  • 38
  • I'm using IIS Express locally and deploying to Azure in production. How do I configure IIS Express like this? Is it a project/solution setting within VS? – TMC Jun 26 '12 at 06:51
  • which IIS Express version you are using? – Waqas Raja Jun 26 '12 at 09:54
0

Use web.debug.config and web.Release.config to manage the development and release environment difference. For more please follow this SO POST or this MSDN blog

Community
  • 1
  • 1
Furqan Hameedi
  • 4,372
  • 3
  • 27
  • 34
  • I tried messing around with this, but this seems better suited to dealing with different configurations due to a difference between dev and prod (such as connection strings). In this case, it's more related to IIS not running the projects together as a single site. – TMC Jun 27 '12 at 04:51