Base solution for your next web application
Open Closed

TenantId is Null by default #7195


User avatar
0
brian.foster created

Hello, I have finished developing my application and everything works locally without error. As soon as I publish the site and go to my registration page, I get an error. I have determine why I'm getting the error, but don't know how to resolve it.

It turns out that I have a function that requires the "unauthenticated" user to be assigned to the default tenant id =1. But when I launch the page, I notice that the following settings are set: session: impersonatorTenantId: null impersonatorUserId: null multiTenancySide: 2 tenantId: null userId: null

But I'm expecting these settings (which is what I get locally): session: impersonatorTenantId: null impersonatorUserId: null multiTenancySide: 1 tenantId: 1 userId: null

I'm confused as to why when I publish the site to azure, it doesn't define the default tenant.

Any Help is appreciated!


5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    You can troubleshoot the problem by determining the tenant.

    https://aspnetboilerplate.com/Pages/Documents/Multi-Tenancy#determining-current-tenant

  • User Avatar
    0
    brian.foster created

    Hi Maliming, That's what I'm trying to figure out. I was able to read through the documentation, but was not able to determine how the Tenant was created? How do you recommend troubleshooting?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @brian.foster

    Default tenant is created when you run the application first time. What is the URL format of your app ?

  • User Avatar
    0
    brian.foster created

    Hi @ismcagdas, My url format is just simply https://askpath-development.azurewebsites.net/. I ultimately determine the tenantId based on the user's email address after they sign in. All registered users go into the default tenantId.

    I just couldn't understand how when I test this locally I saw the default tenantId, but when I published to azure the tenantId wasn't set.

    So I'm assuming when I launch the first time, it considers it to be the host, therefore no tenantId is set. Once I login (using that url) with a user with default tenantId, it sets the tenantId (cache??) to that url?

  • User Avatar
    0
    maliming created
    Support Team

    I just couldn't understand how when I test this locally I saw the default tenantId, but when I published to azure the tenantId wasn't set.

    There may be a cookie named Abp.TenantId in your locally.

    So I'm assuming when I launch the first time, it considers it to be the host, therefore no tenantId is set. Once I login (using that url) with a user with default tenantId, it sets the tenantId (cache??) to that url?

    Will not cache, is still the following rules.