Reputation: 1128
I'm trying to set up a new .NET Core MVC Application to allow all sub-domains for a multi-tenant application. I have added a Route Contraint to enable me to extract the tenant information but can't get my solution to allow any subdomains. I would like to achieve this without having to edit my local Windows hosts file to test. Is this possible?
Upvotes: 1
Views: 1261
Reputation: 476
What I do normally for multi-tenant web apps, are to use a local (or intranet) DNS to translate the domain names, because that way you will have ultimate control of how the domains are translated.
Sample Steps:
1) Set up a local DNS server, and set your local network of the development machine to use the DNS server IP 2) Set up the domain (such local as the domain which I always do, and set *.local to point to your development machine IP, so the subdomain will be siteA.local, siteB.local etc.) 3) In your .NET Core MVC App. listen to a specific port (I normally do it as listening port 80 for HTTP directly - but make sure you run the app with administrator privileges of you want the convenience of port 80 instead of ports like 5000 )
4) viola, enjoy as all subdomain of local (such as siteA.local, siteB.local etc.) will be all pointing to your local development machine, and then having the .NET Core MVC app to serve all the domains
Upvotes: 0
Reputation: 1128
In case anyone else has this "problem", I ended up using a domain that redirects back to my local machine - see this website for details.
Upvotes: 1
Reputation: 6787
You're right, if you run project under iisExpress
you should set some configuration.
but if you run your project with dotnet run
it will let you use any subdomain you want...
Upvotes: 0