Dear Support
I have changed the "Website Root Address" to {TENANCY_NAME}.mydomain.com in Host Settings.
I have also setup the wildcard hostname on Azure *.mydomain.com.
When I navigate to the site <a class="postlink" href="http://www.mydomain.com">http://www.mydomain.com</a> i can see the front end website.
When i click on the login button, I get the following error
Server Error in '/' Application.
There is no tenant defined with name www
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Abp.UI.UserFriendlyException: There is no tenant defined with name www
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[UserFriendlyException: There is no tenant defined with name www]
is this functionality normal, am i supposed to create a www tenant to access the back end?
Should i rename the default tenant to www?
31 Answer(s)
-
0
Hi,
You could redirect <a class="postlink" href="http://www.yourdomain.com">www.yourdomain.com</a> to yourdomain.com in your DNS settings to avoid such a subdomain problem.
But, if you want to make it via code, it's easy: Open SubdomainTenancyNameFinder.cs in your solution and modify GetCurrentTenancyNameOrNull() method to return null if current subdomain is "www". You can do it just before "return values[0];". Example code:
if (string.Equals(values[0], "www", StringComparison.InvariantCultureIgnoreCase)) { return null; }
Thus, <a class="postlink" href="http://www.yourdomain.com">www.yourdomain.com</a> will be used as host address.
-
0
As we know in aspnet core version, the WebSiteRootAddress already move to appsettings.json, if change the WebSiteRootAddress like {TENANCY_NAME}.mydomain.com, use subdomain visit the site, it cannot find the tenant, furthermore on the login page, the change tenant name link disappeared.
If change the WebSiteRootAddress as <a class="postlink" href="http://www.mydomain.com">www.mydomain.com</a>, use subdomain visit the site, although it cannot find the tenant, but on the login page, the change tenant name link can update the tenant name, then login could redirect to tenant admin panel.
Is the feature still works fine? It is difficult to find a specificed tenant by subdomain with this bug.
Any suggestion?
-
0
Hi,
Sorry, this is my mistake, I couldn't understand your explanation at the first time :).
This is actually the expected behaviour. When you set website address to {TENANCY_NAME}.mydomain.com and visit a subdomain, the change tenant name link disappeared if we can find the tenant from subdomain.
When you visit the <a class="postlink" href="http://www.mydomain.com">www.mydomain.com</a>, we cannot find the tenant and change tenant name link becomes visible.
Are you having a problem realted to this ?
-
0
-
0
Hi,
In ABP 1.4.2, this class (<a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.AspNetCore/AspNetCore/MultiTenancy/DomainTenantResolveContributer.cs">https://github.com/aspnetboilerplate/as ... ributer.cs</a>) should solve tenant from domain name.
Can you create a similar class, for example MyDomainTenantResolveContributer and add it to tenancy resolvers in your web module's PreInitialize method and write soem logs to see if it can find tenant or not.
You should add your custom resolver as the first resolver, because there are some other resolvers added here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/9c701cb6e85d3f603eebd7b704824cdb1e3f2c02/src/Abp.AspNetCore/AspNetCore/AbpAspNetCoreModule.cs#L36">https://github.com/aspnetboilerplate/as ... ule.cs#L36</a>.
Thanks.
-
0
Follow up your suggestion, it still cannot resolve the issue, your approach will lose the tenant, it will cause current tenant user cannot login.
I think this is a bug, remove "http://" or "https://" already implemented in [https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.AspNetCore/AspNetCore/MultiTenancy/DomainTenantResolveContributer.cs])
@ ismcagdas , What do you think?
-
0
Hi @trendline,
Can you send your project to <a href="mailto:[email protected]">[email protected]</a> ? I can create a subdomain environment in my local machine and test this case for you. It is hard to find the problem without debugging it.
-
0
Hi,
We have found a bug related to this, see <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1907">https://github.com/aspnetboilerplate/as ... ssues/1907</a>. For now, you can remove http:// from your WebSiteRootAddress in appsettings.json.
So you will have something like
"App": { "WebSiteRootAddress": "{TENANCY_NAME}.mydomain.com" },
When we release new version of ABP, you can convert it back if you like.
-
0
After applied this <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1907">https://github.com/aspnetboilerplate/as ... ssues/1907</a> fix, it still cannot resolve my issue that I mentioned before, it is strange sometimes it could find the tenant, sometimes it cannot find the tenant, sometimes it will use host user information instead of the expected Tenant.
Could you have a look again?
-
0
I have created a similar class like DomainTenantResolverContributor and add the resolver in the Web Module in the MVC project, but when debug it the HttpContext is null
var httpContext = _httpContextAccessor.HttpContext; if (httpContext == null) { return null; }
Did you get the similar exception before?
-
0
Hi,
We didn't get a similar exception before but we helped a customer recently for subdomain problem with angular2 project. I think you might have the same case.
The problem was the / character at the end of WebSiteRootAddress value in host project's config. So you need to use a config like this.
"WebSiteRootAddress": "http://{TENANCY_NAME}.mydomain.com"
Dont put a / at the end of WebSiteRootAddress value.
For DomainTenantResolveContributor, are you adding it in PreInitialize method of your module ?
Thanks.
-
0
Yes, I put it in the PreInitialize method of Web Module in MVC project, but not remove "/" at the end of the WebSiteRootAddress, when debug it on dev machine sometimes it throw HttpContext is null.
But, I deployed this changes to production, it works as expected, really a little strange. I also extended some customized code to match a customized Host per tenant, code like below:
//Find independency hosts var tenants = from t in _tenantRepository.GetAllList() select t; string[] hosts = null; foreach (var item in tenants) { if (!item.Hosts.IsNullOrEmpty()) { if (!item.Hosts.Contains(",")) { hosts = new string[1]; hosts[0] = item.Hosts; } else { hosts = item.Hosts.Split(',').Length > 0 ? item.Hosts.Split(',') : null; } if (hosts.Count() > 0) { foreach (var host in hosts) { if (host.ToLower() == domainFormat.ToLower()) { Logger.Info("TenancyName:" + item.TenancyName); return item.Id; } else { continue; } } } } }
Is the DomainTenantResolverContributor check each request? If that, I need to cache the tenant results from repository.
-
0
I hosted Core API on service.abc.com without wildcard and Angular App hosted on {Tenant_Name}.abc.com with wildcard.
As per your provided configuration, Tenant name is also include in "ServerRootAddress": "http://{TENANCY_NAME}.service.abc.com"
do we also need wildcard for the Core API ?
Please give me the solution for this I have only on wildcard and IP server, how can i implement multi tenancy ?