4

I'm running IIS 7 on Windows 7 and would like to setup wildcard subdomains to test out an ASP.NET multi-tenant application that uses the subdomain to identify the user. How can I achieve this?

Omar
  • 195
  • 3
  • 14

1 Answers1

7

Update 2016

IIS 10 in Windows 2016 supports wildcard host headers.

Origin answer

Unfortunately IIS 7 still doesn't support wildcard mappings for subdomains (or any part of the domain binding).

You have a few options:

  • If you can ensure the site only receives traffic on one IP and you own/have dedicated access to the server, you can use DNS to "fake" out the behavior with a wildcard mapping and no host. There is a great post on this at http://dirk.net/2008/05/28/wildcard-host-header-binding-and-subdomains-with-iis7

  • Simply let the site respond to all traffic, or all traffic using a supported binding, and let ASP.NET handle the subdomain processing. Basically everything hits IIS and ASP.NET, and then you use code for the sub-domain control. Your APP is at the root, and the subdomains and simply used by the app to obtain the user info.

  • Use some sort of traffic control/url-rewrite module to rewrite requests to user or user2.domain.com to just app.domain.com (or whatever) with some additional header (i.e. 'X-UserInfo') that contains the username, and your app handles the username that way

Oleg Neumyvakin
  • 629
  • 6
  • 16
Taylor
  • 394
  • 1
  • 3
  • The link above is broken...do you know where I can read about this? – Chris Muench Feb 02 '15 at 19:47
  • Well actually I had done exactly the same thing before but now as there are some other sites on my server I wasn't able to create a website without host name but assigning a dedicated ip solved the problem (this one I didn't know) Thanks a lot – Ashkan Mobayen Khiabani Aug 17 '15 at 18:53