IT:AD:IIS Express:HowTo:Handle Branching
Summary
IIS Express works…most of the time.
It's those other times, that things go to hell.
The most common scenario I've seen is when
- Copying a website to a new location, and relaunching it (different paths)
- Creating and opening a Branch of an application.
Process
The problem is what's saved in the
%UserProfile%\Documents\IISExpress\config\applicationhost.config
When you got the first website working, it created a section as follows:
<configuration>
...
<sites>
...
<site name="App.AppHost.Web-Site" id="3">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\CODE\App15\App.Core.Back.AppHost.Web" />
</application>
<application path="/NSI_App" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\CODE\App15\App.Core.Back.AppHost.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:17001:localhost" />
</bindings>
</site>
</sites>
</configuration>
All good.
Then you switch to the new branch, and it doesn't work (because you're now in D:\CODE\App16\ and when you start VS it starts IIS Express, which is pointing an app with the same name still towards D:\CODE\App15...)
So you fix it by
* In VS, selecting the option to “Create a Virtual Directory”
* or opening the applicationhost.config file,
* or doing things very properly using appcmd.exe from within the %UserProfile%\Documents\IISExpress\config directory.
Now your applicationhost.config file looks like:
<configuration>
...
<sites>
...
<site name="App.AppHost.Web-Site" id="3">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\CODE\App16\App.Core.Back.AppHost.Web" />
</application>
<application path="/NSI_App" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\CODE\App16\App.Core.Back.AppHost.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:17001:localhost" />
</bindings>
</site>
</sites>
</configuration>
You're good to go, until you open up branch 1…or both branch 1 and 2 at the same time.
The ugly truth is that there is no easy way. You just have to be aware of it, and edit the config file as you switch branches.