Search code examples
c#asp.netsubdomainasp.net-routing

How to have same URL for different web applications


I have a project that contains 2 web application and I want to use same URL to access the two application

1) admin site used by company : appcompany.com

  • a web forms application

2) general site used by company's customers : [CUSTOMER_ID].appcompany.com

  • also a web forms application but used ROUTING to determine the customer from the sub-domain.

Currently, typing appcompany.com in the browser takes you to the home page indicating no customer specified

Typing 123.appcompany.com takes you to a page customized for customer 123.

As said earlier, the general site application can determine when no customer was specified and could redirect - but redirecting to the admin site may require another URL since they are different project

The problem is I don't know how to make appcompany.com go to the admin site without having 2 URL(s).

UPDATE

I am using asp.net ROUTING to simulate sub-domain routing in case I don't have privilege to multiple physical sub-domains


Solution

  • You need to specify it in IIS adminitrator. You need to create 2 different applications:

    • 1) for the admin site
    • 2) for the customer apps

    Each of this one have to point to the physical directory where you implement your applications.

    Then you have to edit the bindings:

    • for 1) add only one host header "appcompany.com"
    • for 2) you need to add one host header for each customer: "cust1.appcompany.com", "cust2.appcompany.com" and so on

    IIS will redirect each request to the specified app: You should add the binding for each company in the same moment where you add the DNS entry for it.