Hello,
i'm currently trying to get the CurrentTenant
information within the context of a custom IMenuContributor
. When the ConfigureMenuAsync
executes on the server side the current tenant id is properly populated from the ICurrentTenant
implementation but it is null when executing for web assembly. Here's my ConfigureMainMenuAsync
from a custom IMenuContributor
which is properly registered on the menu contributors
private static async Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{
var l = context.GetLocalizer();
var currentTenant = context.ServiceProvider.GetRequiredService<ICurrentTenant>();
// Prints the current tenant id/name on the server
// Prints null on web assembly
Console.WriteLine($"Current tenant is {currentTenant.Id}: {currentTenant.Name}");
if (currentTenant.Id == null)
{
// Custom logic for the Host
}
}
Any ideas why that is?
Thanks !!
4 Answer(s)
-
0
Hi,
I created a Blazor Web App project from scratch to reproduce your problem.
This application uses ABP packages with version 9.1.0.
I added the code you mentioned as in the picture but I could not reproduce the problem:
Result:
Can you create a project from scratch and try to reproduce this situation to make sure that the problem belongs to your case? If you can reproduce the problem in a project created from scratch, let me know the version of the project you created, etc. and I will try.
-
0
Thanks for the response.
Unfortunately it seems I can reproduce the issue even on a new microservice solution.
I'm on version 9.1
Steps to reproduce on my side:
-
Create a new microservice solution from the abp studio
-
EF Core database provider
-
Multitenancy enabled
-
Blazor WebApp as the UI framework
-
No mobile framework
-
No public website
-
No dynamic localization
-
OpenIddict UI enabled
-
LeptonX theme
-
Add this block in the .Client assembly in the MenuContributor file
var currentTenant = context.ServiceProvider.GetRequiredService(); Console.WriteLine($"Running on the browser: {OperatingSystem.IsBrowser()} Current tenant is {currentTenant.Id}: {currentTenant.Name}");
-
Run the solution and create a tenant
-
Login on that new tenant and notice the empty tenantid/tenantname in the console
-
-
-
0
Hi,
Thanks to the information you provided, I was able to reproduce the problem. The problem does not occur in the Application Layered template, but in the Microservice solution, so I could not reproduce it the first time. I will create an internal issue, and we will keep you informed about the progress. Thank you for your patience.
-
0
Hi,
Thanks to the information you provided, I was able to reproduce the problem. The problem does not occur in the Application Layered template, but in the Microservice solution, so I could not reproduce it the first time. I will create an internal issue, and we will keep you informed about the progress. Thank you for your patience.
Thank you,
I'll wait for an issue link to track the progress