Closed skeww closed 4 years ago
Are you using 6.x? You should be able to get the tenant info straight out of DI. If you have MyTenantInfo
as the type for your tenant class you can inject or resolve from DI directly.
You can also use IMultiTenantContextAccessor<T>
where T
is your custom info type. This should work well in Blazor, but let me know if you still have the issue.
Yes, I am using 6. I ended up creating a tenant service with a reference to my tenant store. It's working (I can get a tenant list and the current tenant from the host name.)
@skeww Excellent, sounds like you have a nice solution there!
Are you using 6.x? You should be able to get the tenant info straight out of DI. If you have
MyTenantInfo
as the type for your tenant class you can inject or resolve from DI directly.You can also use
IMultiTenantContextAccessor<T>
whereT
is your custom info type. This should work well in Blazor, but let me know if you still have the issue.
Hi @AndrewTriesToCode !! what do you mean by "you can inject or resolve from DI directly"? All I can found in samples and everywhere is through HttpContext.GetMultiTenantContext.
I found this page issue https://github.com/Finbuckle/Finbuckle.MultiTenant/issues/188
However, a document that went up later (May 2020) on Microsoft docs (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-context?view=aspnetcore-3.1) says:
"Additionally, again for security reasons, you must not use IHttpContextAccessor within Blazor apps. Blazor apps run outside of the context of the ASP.NET Core pipeline. The HttpContext isn't guaranteed to be available within the IHttpContextAccessor, nor is it guaranteed to be holding the context that started the Blazor app."
I have implemented the IHttpContextAccessor solution, but sometimes I get a null reference and can't get the tenant name.
Has anyone found a workaround for getting the tenant info in a blazor page?