I'm trying to get an MVC3 application with a WCF service as a child application working as expected in IIS Express. It works fine in IIS but is doing something strange in IIS Express.
When I run the site in IIS the config settings from both the child and parent applications are available within the child application. However, when I run the same code in IIS Express only the parent config settings are available.
I can't find any documentation on this being an expected behavior. That doesn't rule it out but I'm inclined to suspect I have a configuration issue.
The question is, how can I run these sites in IIS Express without losing the settings applied in the child application?
I'm using a Windows 7 box with Visual Studio 2010, MVC3 and IIS Express 8.
Here is the site configuration in my applicationhost.config file.
<site name="ParentMvcApp" id="7">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="c:\users\<username>\documents\visual studio 2010\Projects\ChildAppTest\ParentMvcApp" />
</application>
<application path="/Services/ChildWcfApp" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="c:\users\<username>\documents\visual studio 2010\Projects\ChildAppTest\ChildWcfApp" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:33888:localhost" />
</bindings>
</site>
Here is the MVC config file contents.
<configuration>
<appSettings>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages"/>
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:33888/Services/ChildWcfApp/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
Here is the WCF service config file contents.
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="Test"
value="Wtf"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I finally found the issue. My sub applications were 2 levels deep. Unfortunately, in this instance IIS Express does not act like full blown IIS. Even though they were configured as applications IIS Express was not reading their config files. I had to explicitly add a virtual directory configuration for the parent folder that had the allowSubDirConfig attribute set to true.
<virtualDirectory path="/Services" allowSubDirConfig="true" />