Configure DNS Aliases in IISExpress for localhost

A direction we are taking Process PA is white labelling for our partners. To do this we are still hosting on the same scalable platform on Microsoft Azure and essentially adding another level of multi-tenanting in our codebase. When a user navigates to they will get our first party branded experience. However, when a user navigates to something like, they will get a tailored experience complete with branding, different resources, templates and features specific for those customers supported by our partners.

Building out the experience using Dependency Injection with Branch By Abstraction based on the host is reasonably straight forward. I however wanted the local development environment to be run in the same way, rather than switching in code for whatever partner experience was being built out at the time. To do this I need to be able to configure local DNS records for localhost and IISExpress. The answer I found on StackOverflow but below are the simplest steps that worked for me.

  1. Open Notepad as an Administrator
  2. Open in Notepad C:\Windows\System32\drivers\etc\hosts
  3. Copy the comment lines for localhost host and add as your DNS records    partner1.localhost
    ::1          partner1.localhost
  4. For Visual Studio 2015, open <Solution folder>\.vs\config\applicationhost.config
  5. Find the site and add the bindings you need, making sure to change the ports.
    <binding protocol="http" bindingInformation="*:1704:localhost" />
    <binding protocol="https" bindingInformation="*:44300:localhost" />
    <binding protocol="http" bindingInformation="*:1705:partner1.localhost" />
    <binding protocol="https" bindingInformation="*:44308:partner1.localhost" />
  6. To prevent the need to run Visual Studio as admin to start IISExpress on those ports, open an Administrator command prompt and run:
    netsh http add urlacl url=http://partner1.localhost:1705/ user=machine\username
    netsh http add urlacl url=https://partner1.localhost:44308/ user=machine\username

If you have certificate trust issues check out:

And that’s it! When you go to https://localhost:44300 or https://partner1.localhost:44308 you get the same application with a different experience.