Add User to Role throws Exception

I add an Issue here - I hope this was the right place?

Hi @ccre-support,

You need to specify unique host for each tenant otherwise the application will retrieve always the first tenant with the current host.

Ok, understood.

But if the tenantadmin is running the app and is assigning users to roles within the tenant, this seems to not work.

The app will run on localhost: 5001 for example with tenantadmin logged in.

The tenant admin's job is to create roles and add users for each tenant.

How will the app know, (when GetTenant() function is called), which Tenant they are working on?

When you are logged with tenantsadmin you can switch current tenant from the DataGrid in the tenants page.

ok, I made some changes so that the value for each Tenant.Host was unique.

Next I ran the sample app again but still got the same failure.

image

I’m afraid that I don’t know what this error means and I’ve never seen it before. Please make sure that your database is in sync with the code - i.e. all the migrations are applied properly. Make sure also that you don’t have users/roles created and associated with wrong tenant because of the duplicate hosts.

Just to confirm - maybe I'm misunderstanding. So is the following statement true or false?

The tenantadmin account (ie the one that has null TenantId) can log in and:

  1. create tenants,
  2. create Roles in a any tenant (using the tenant switch functionality)
  3. add users to roles in any tenant (using the tenant switch functionality)

ok will double check and get back

OK, I think I understand the way multi-tenanted is working here.

So, if I change the start-up url to match the Tenant.Host value I can carry out normal operations without error for each Tenant.

It does leave me asking how this design of a multi-tenanted application is going to be used or deployed in practice.

The common design of multi tenanted is for a single URL to cater for many tenants.
This design means, if I'm not mistaken, I would need to deploy a separate website for each tenant.

Would that be correct?

I'm not implying this is good or bad, just wanting to fully understand your thinking.

best wishes,

John

This is not how Radzen multi-tenants application works. The app should be hosted on different hosts for each tenant. This is not something new for Radzen Blazor Studio - it comes from Radzen IDE several years ago when we added this feature:

ok I see - thanks for the confirmation and sorry I went on a wild goose chase.

ps - you may want to update the documentation as it is a little misleading when looking at this pic and seeing the same url in both tenants.

Also this sentence needs to be retracted as it is contrary to your earlier statement.

Radzen needs single App instance for each tenant.

Best regards,
John

That's not true. The app and the database are the same - only the IIS virtual folders/applications are different.

Yes you are right. For IIS this is true but for cloud I'm not so sure - maybe I'm not informed enough to know how to do this in the cloud e.g.Azure

You should be able to add multiple hosts for your azure app too. There is also a way to do that in IIS so you have only one web site per app instead of tenant.