Enabling Subdomains on IISExpress (localhost) for test multitenancy

Views: 7459
Comments: 1
Like/Unlike: 1
Posted On: 28-Sep-2016 23:12 

Share:   fb twitter linkedin
NiceOne...
1390 Points
18 Posts

Introduction

As a developer some time we need to create sub-domains with IIS Express in local machine for testing. In order to test it on a development machine, a couple of small additions needs to be done to allow subdomains with localhost (e.g. tenant1.localhost) together with IIS Express. This article helpfull for configuring such environment.

Description

Follow the following easy steps

I) Open Visual Studio in Run As Administrator

II) Open Project in which you want to test multitenancy

II) Find applicationHost.config file and edit it as:

a) Run Project in Debug mode

b) Now you can see in notification area iisexpress icon as

c) Right click on this icon- click on show all applications

d) Now you can see the links

e) Click on config link. This is the applicationHost.config file

III) Visual Studio usually handles editing this file for you when you make configuration changes, but you can manually edit. Check following section in file

<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>

Find the particular site you are working with and add following bindings should work:

<bindings>
<binding protocol="http" bindingInformation="*:10359:localhost" />
<binding protocol="http" bindingInformation="*:10359:testsubdomain.localhost" />
</bindings>

You can really change the port to anything you want so you could use 80 to save yourself some typing. Continue adding bindings to fill out your multi-tenancy as needed.

IV) Now Stop Debug and Start again

Note: Visual Studio should be run as Administrator

Conclusion

In above example we learn how to use sub-domains in localhost. I hope it will helpful for develper who want to configure sub-domains for testing multitenancy.

1 Comments
Great...

Rahul Kiwitech
20-Oct-2016 at 02:22
 Log In to Chat