Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Multi tenant subdomain issue when hosting in a sub-website #4947


User avatar
0
ubiquo created

Hi, I was having trouble to login into a tenant using a subdomain as I mentioned in this post [https://forum.aspnetboilerplate.com/viewtopic.php?p=28437#p28437]).

My settings look like this

"remoteServiceBaseUrl": "http://{TENANCY_NAME}.mydomain.com/Host",
"appBaseUrl": "http://{TENANCY_NAME}.mydomain.com/Angular"
"ServerRootAddress": "http://{TENANCY_NAME}.mydomain.com/Host",
"ClientRootAddress": "http://{TENANCY_NAME}.mydomain.com/Angular"

Host and Angular are sub-website in IIS.

Apparently in the DomainTenantResolveContributor there is a problem matching the host in the request headers and the multitenancy domain format (which is the ServerRootAddress), and because of that I was only able to login with the host users.

var hostName = httpContext.Request.Host.Host.RemovePreFix("http://", "https://");
var domainFormat = _multiTenancyConfiguration.DomainFormat.RemovePreFix("http://", "https://").Split(':')[0];
var result = new FormattedStringValueExtracter().Extract(hostName, domainFormat, true);

if (!result.IsMatch)
{
    return null;
 }

var tenancyName = result.Matches[0].Value;
if (tenancyName.IsNullOrEmpty())
{
   return null;
}

If I remove the sub-website from ServerRootAddress "http://{TENANCY_NAME}.mydomain.com" I'm able to login into any tenant, but I'm not sure if this is the right way to do it.

Is there any problem if I leave the ServerRootAddress without the sub-website?


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ubiquo,

    You can remove the sub address for your host website for now. It shouldn't cause any problems. It will be fixed in this issue <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3254">https://github.com/aspnetboilerplate/as ... ssues/3254</a>.