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

{TENANCY_NAME}.mydomain.com #1230


User avatar
0
vnetonline created

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)
  • User Avatar
    0
    vnetonline created

    Can someone please answer this??

  • User Avatar
    0
    hikalkan created
    Support Team

    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.

  • User Avatar
    0
    vnetonline created

    Thanks for the above ... that works perfectly.

    However, When i type in {TENANCY_NAME}.mydomain.com. I would like to go directly to the login page. How can i implement this??

  • User Avatar
    0
    hikalkan created
    Support Team

    If you don't need to a frontend page, go to HomeController and redirect to the Application Controller's Index action (for SPA).

  • User Avatar
    0
    vnetonline created

    Thanks for the info, I was thinking that but I only want to redirect certain subdomains straight to the login page? What is the best way of implementing this?

  • User Avatar
    0
    hikalkan created
    Support Team

    So, you can check subdomain and decide to redirect or not. You can get it from HttpContext.Current.

  • User Avatar
    0
    trendline created

    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?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Which version of ABP do you use in your project ?

    Thanks.

  • User Avatar
    0
    trendline created

    Version 1.4.2

  • User Avatar
    0
    ismcagdas created
    Support Team

    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 ?

  • User Avatar
    0
    trendline created

    Yes, the behavior just like you said, on the UI the process is that.

    But, when I using tenant1.mydomain.com visit the site, in fact the application doesn't found the tenant, if using the user of the tenant sign in system then will failed.

    This is the issue that I encountered now.

  • User Avatar
    0
    ismcagdas created
    Support Team

    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.

  • User Avatar
    0
    ianmark89 created

    You can fix it by removing http// or https:// like this one "WebSiteRootAddress": "{TENANCY_NAME}.yourdomain.com"

  • User Avatar
    0
    trendline created

    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?

  • User Avatar
    0
    ismcagdas created
    Support Team

    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.

  • User Avatar
    0
    trendline created

    Thanks, I already sent a mail to you, please check.

  • User Avatar
    0
    ismcagdas created
    Support Team

    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.

  • User Avatar
    0
    cangunaydin created

    I am having this problem too. But changing it to {TENANCY_NAME}.mydomain.com isn't solved the problem do you have any idea about this?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You problem is a bit different because in angular2 app's host project uses this address for CORS policy. I have replied your question as well.

  • User Avatar
    0
    trendline created

    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?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share the configuration values for your application ? Like, website root address values.

  • User Avatar
    0
    trendline created

    the configuration in my appsettings.json file like below:

    "App": { "WebSiteRootAddress": "http://{TENANCY_NAME}.mydomain.com/" },

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Do you use any https addresses in your app ? If not, do you have an example address for your below comment ?

    it is strange sometimes it could find the tenant, sometimes it cannot find the tenant
    
  • User Avatar
    0
    trendline created

    No HTTPS enable.

    I will send you the demo URL via email.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Thanks, I have replied your email.