Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor support #16

Open
haipk opened this issue Jun 18, 2020 · 1 comment
Open

Blazor support #16

haipk opened this issue Jun 18, 2020 · 1 comment

Comments

@haipk
Copy link

haipk commented Jun 18, 2020

Hello,

I use your library in my Blazor project server side.

With RenderMode.ServerPrerendered mode the Blazor will load 2 times, at the first time I can get the tenant name but at the second time the TenancyContext is null.
But when I switch to RenderMode.Server, it will load 1 time and the TenancyContext is always null.
Can you give me any suggestion to fix it?

Thanks.

@haipk
Copy link
Author

haipk commented Jun 19, 2020

I resolve by adding ITenancyProvider into my constructor and getting tenant name from it. I check if the context is null I will get the tenant from TenancyProvider

if (tenancyContext.Tenant != null)
_tenancyContext = tenancyContext;
else
{
var task = Task.Run(async () => await tenancyProvider.GetCurrentTenantAsync());
_tenancyContext = new TenancyContext
{
Tenant = task.Result
};
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant