IIS Website with multiple sub names RRS feed

  • Question

  • User2021055510 posted

    I have developed an asp.net application. I will host the application as a new website in IIS.

    I want to work the application like below,

    1. http://localhost:81/firm1/login
    2. http://localhost:81/firm2/login

    All the above 3 calls need to hit my website and I will do some process with the names 'firm1', 'firm2'.

    I dont want to create multiple websites/virtual applications or sub domains.

    Kindly suggest me the possible ways.

    Thanks in advance!

    Monday, June 26, 2017 6:03 AM

All replies

  • User-359936451 posted

    localhost is not a web site, its a development environment. You can use IIS to host multiple sites on all MS OS's from Win 7 up. You would create unique Host Header names for each site. You would also need to update the hosts file on your local computer to point to your IP address for each name you decide to use. This will only work on your computer though, or you would need to update the hosts file for each computer on your network, or find some other means, usually DNS, to route calls to the web sites to your PC. This might sound a like a complex process but it really isn't.

    Ideally, it sounds like what you might really want is just one web site, then based on the user login, redirect them to a specific location in the site. Their section. You can do this with Roles, so each user has a Role and when they each login, depending on their Role they are redirected to a specific page.

    But to answer your question, search for info on how to edit your host file, you should end up with something like this.

    111.222.333.444    mysite1

    111.222.333.444    mysite2

    In IIS on your PC you would create a unique web site for each of these names. In IIS (Win10), expand the computer name, right click on the Sites folder, Add Web site and follow the prompts. You will point this site to the home page folder for mysite1, repeat the steps for mysite2. Make certain you enter a unique name or each site in the Host name text box, and this name must exactly match what you enter in the Hosts file.  Now when you enter mysite1 or mysite2 in any browser on your PC you land on the page you assigned in IIS.

    Tuesday, June 27, 2017 2:01 PM
  • User753101303 posted


    Basically you want to have a tenant name as part of your route ? Try for example https://stackoverflow.com/questions/1699913/setup-a-route-tenant-controller-action-id-with-asp-net-mvc (ie include a {tenant} portion as a part of your route).

    Tuesday, July 11, 2017 9:40 AM