How to configure IIS wildcards for account subdomains (like Basecamp)?

In effect I'm working on a SaaS application where I want to give subscribers their own subdomain to access their information (in code I will be pulling the first part of the subdomain for use as their account name), similar to how Basecamp et all work. For instance, a subscriber might have the URL acme.myapp.com. Since there could be hundreds of subscribers I can't simply add a different host header for each client.

Apache allows you to specify a wildcard (*) and will redirect acme.myapp.com to myapp.com, wherein I can perform my logic to retrieve the user's account name based on the subdomain. I'm not sure how to automatically do this with IIS (It's been a while since I've had to configure IIS for anything except a single website).

Also, is there any special provisions that I need to accomplish this? When my app is ready and I'm looking at hosting for it, will I need anything specific from the host that would limit my choices? I was also considering using Windows Azure to take advantage of the cloud - would I still be able to do this if I went with Azure as a hosting platform?


Solution 1:

As Joe mentioned you would do this more with DNS than IIS.

IIS does not have support for *.domain.com wildcard domains. Instead you would create a site in IIS that had no host headers, so would respond to all requests on that IP that were not picked up by other sites that did have host headers. You would then create your wildcard DNS entry to point to the IP of that site and your done.

Solution 2:

If I'm understanding you correctly, you could use DNS to do this. Assuming that myapp.com is your domain, then in your myapp.com DNS zone simply add a CNAME record (acme) that points to the A record for your web site (www.myapp.com). That will send them to your main web site, where your code will take over and redirect them to the appropriate application.

You could also use a DNS wildcard record (*) which will catch everyting, such as acme.myapp.com, joeschmoe.myapp.com, etc.