Multitenant Episerver Sites on IIS Express
IIS Express allows for fast, license-free local development. But, it has its downsides as well. Blend's Director of Development Bob Davidson explains how to navigate IIS Express in order to bind multiple Episerver sites and languages in this Coding with Bob video.
Many developers prefer IIS Express for local development over using the full IIS install. I am among them, for several reasons:
- Episerver running in IIS Express and answering to the
localhostdomain does not require a license. Demo licenses are free to partners, but mildly annoying manage.
- To debug in full IIS, you must run Visual Studio as Administrator. It may just be my setup, but this seems to be a frequent cause of problems for me. Running as the current user, however, is very stable.
- Because the IIS worker process is running as the current user, I can use a Trusted Connection to my SQL Server connections. That's one fewer password to concern myself with.
But IIS Express comes with one glaring downside:
- You can only use
localhostas the domain.
This appears to be particularly problematic for Episerver, as Episerver distinguishes different tenants and (optionally) different languages by domain. Fortunately, that's not 100% accurate. Episerver distinguishes these by authority.
The difference here is that a domain is just the name (
www.google.com for example), but authority is the domain and the port (
www.google.com:443 for example).
In IIS Express, we can only bind to the
localhost domain, but we can bind to any number of ports. By leveraging both, we can create unique authorities (domain and port), and thus bind multiple Episerver sites and languages with IIS Express.
Doing this is not difficult. Here's a video that goes through in more detail.
Video summary steps.
Follow these steps:
1. In the root folder of your project, you'll find a
.vs folder. Open it.
2. Within that folder, you'll find a project with the same name as your solution. Open it.
3. Finally, you'll find a folder called
config. Open that. You should now be in a path that roughly resembles
4. Here, there will be an
applicationhost.config file. Open that in a text editor.
5. This file is the configuration file for IIS Express. It is nearly identical to the configuration file used by full IIS. Within it, you will need to find the
site node for your project. Look for a
site node with a
name that matches your project. It will look something like this:
<site name="Alloy" id="2"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="C:\Data\Working\Presentations\AlloyDemo\Alloy" /> </application> <bindings> <binding protocol="http" bindingInformation="*:53430:localhost" /> </bindings> </site>
6. Add as many
binding nodes as you need. For example, to have a total of 3 authorities for languages and sites, you would add two more nodes, giving each a new port number:
<site name="Alloy" id="2"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="C:\Data\Working\Presentations\AlloyDemo\Alloy" /> </application> <bindings> <binding protocol="http" bindingInformation="*:53430:localhost" /> <binding protocol="http" bindingInformation="*:53431:localhost" /> <binding protocol="http" bindingInformation="*:53432:localhost" /> </bindings> </site>
7. Exit IIS Express completely, and restart it.
8. Configure Episerver for the new authorities the way you would for domains. Be sure to include the port numbers when configuring.
The impression I've gotten is that this isn't exactly an officially supported approach, but it's served me well over the years.
Blend's Director of Development, Bob Davidson, provides tutorials on all things development.
His web series, Coding with Bob, can be found on Youtube. Check it out!