Base solution for your next web application
Open Closed

Sub-Domain support? #520


User avatar
0
josemalone created

Hi.

First off, I want to say thank you for making such an awesome project! The timing is great since I've been trying to find a way to incorporate a multi-tenant solution to a project I'm creating.

Maybe I'm missing this, but is the ability to offer sub domain names available? Have you thought about this? I've been investigating making an OWIN middleware to map this. Anyway, wondering what your thoughts are on this feature?

Thank you!


5 Answer(s)
  • User Avatar
    0
    daws created

    IN ABP, <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Zero/Tenant-Management">http://aspnetboilerplate.com/Pages/Docu ... Management</a>

    TenancyName: This is unique name of a tenant in the application. It should not be changed normally. It can be used to allocate subdomains to tenants like 'mytenant.mydomain.com'. Tenant.TenancyNameRegex constant defines the naming rule.

    In ASP.NET Zero documentation, there is some explaination. <a class="postlink" href="http://aspnetzero.com/Documents/Development-Guide#using-tenancy-name-as-subdomain">http://aspnetzero.com/Documents/Develop ... -subdomain</a>

    I think that's just a matter of url/ip redirection.

  • User Avatar
    0
    josemalone created

    <cite>daws: </cite> I think that's just a matter of url/ip redirection.

    Easy for you to say! ;-)

    I'm still getting my head around this framework, and not a strong programmer. I stumbled on this project through a convoluted web search.

    In looking in RouteConfig.cs I'd expect something like this to be there. I know this isn't correct. But what else am I going to have to tweak to make this work?

    routes.MapRoute(
                     name: RouteConfig.TenantName,
                     url: "{" + RouteConfig.TenantName + "}/{controller}/{action}/{id}",
                     defaults: new { tenent = Tenent.DefaultTenentCode, Controller = "Home", action = "Index", id = UrlParameter.Optional}
                       );
    

    Sorry for such a general request, but I found this trying to figure out what others have done to offer a persistent subdomain when users login to their account. I was researching middle-ware options when I stumbled upon this project.

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    There are different ways to implement it. I implemented the most simple one for AspNet Zero (<a class="postlink" href="http://www.aspnetzero.com/">http://www.aspnetzero.com/</a>). Try to create a demo, you will see that it dynamically creates subdomains.

    How to do it? See "HOST SETTINGS" section in this document: <a class="postlink" href="http://www.aspnetzero.com/Documents/Development-Guide">http://www.aspnetzero.com/Documents/Development-Guide</a>

    So, all *.mydomain.com requests are redirected to the same app on iis. Then I get tenant name from URL.

  • User Avatar
    0
    vincedc created

    <cite>hikalkan: </cite>

    So, all *.mydomain.com requests are redirected to the same app on iis. Then I get tenant name from URL.

    I am sorry. Does your solution is implemented by using special route configuration? Or do you simply parse the url to extract the subdomain.

  • User Avatar
    0
    hikalkan created
    Support Team

    do you simply parse the url to extract the subdomain.

    yes, exactly. But, this works only all subdomain requests come to my asp.net application. That's why IIS should map all subdomains to my app. Then I can extract subdomain name and find tenant name.