Sahil Kataria

Sahil Kataria

  • 697
  • 1.3k
  • 1.6k

Programmatically create subdomains on IIS with ASP.NET MVC

May 20 2015 4:35 AM
So, here are my requirements. I am building a multi-tenant site where companies after they sign up get their own subdomain.
Assume that my business is called Email Jobs Inc with domain www.emailjobs.com. This site is hosted in a shared ISP environment so I have very limited access to IIS etc.

Just to clarify, here is an example of what I need:

company1 signs up and they get this url company1.emailjobs.com
company2 signs up and they get this url company2.emailjobs.com
company3 signs up and they get this url: company3.emailjobs.com

My understanding is that there is a DNS and IIS component to this. That is, I will need to change an entry in a DSN server and then also a binding in IIS. All this is very tricky, because of non-static IP addresses, etc. etc.

However, another option I heard of is to ask your ISP to setup an IIS wildcard option where *.emailjobs.com goes straight to my ASP.NET MVC server. There I can parse the URL, extract the subdomain and I would be in business! Right?

Could someone confirm that this is possible and correct?

I realize that another option I have is to build urls like this: www.emailjobs.com/company1 etc, but that would be far less elegant.
Any feedback would be greatly appreciated...

Best.