Session.TenantId is null! Possible problems: No user logged in or current logged in user in a host user (TenantId is always null for host users)
See original GitHub issue- Abp package version: ASP.NET Boilerplate 5.0.0
- Base framework: .NET Framework (4.7.2)
I’m migrating an application from ASP.NET Boilerplate 4.1 to 5.0 and, despite the fact that multi tenancy has been explicitly disabled in CoreModule.cs (Core project) with:
Configuration.MultiTenancy.IsEnabled = KBConsts.MultiTenancyEnabled; // Set to FALSE
I get this error before the application starts:
Session.TenantId is null! Possible problems: No user logged in or current logged in user in a host user (TenantId is always null for host users).
[AbpException: Session.TenantId is null! Possible problems: No user logged in or current logged in user in a host user (TenantId is always null for host users).]
Abp.Runtime.Session.AbpSessionExtensions.GetTenantId(IAbpSession session) in D:\Github\aspnetboilerplate\src\Abp\Runtime\Session\AbpSessionExtensions.cs:35
Abp.Configuration.SettingManager.GetSettingValueForApplicationOrNull(String name) in D:\Github\aspnetboilerplate\src\Abp\Configuration\SettingManager.cs:723
Abp.Configuration.SettingManager.GetSettingValueInternal(String name, Nullable`1 tenantId, Nullable`1 userId, Boolean fallbackToDefault) in D:\Github\aspnetboilerplate\src\Abp\Configuration\SettingManager.cs:556
Abp.Configuration.SettingManager.GetSettingValue(String name) in D:\Github\aspnetboilerplate\src\Abp\Configuration\SettingManager.cs:68
Castle.Proxies.Invocations.ISettingManager_GetSettingValue.InvokeMethodOnTarget() +89
Castle.DynamicProxy.AbstractInvocation.Proceed() +102
Castle.DynamicProxy.AbstractInvocation.Proceed() +206
Castle.Proxies.SettingManagerProxy.GetSettingValue(String name) +182
Abp.Web.Localization.CurrentCultureSetter.GetDefaultCulture() in D:\Github\aspnetboilerplate\src\Abp.Web\Web\Localization\CurrentCultureSetter.cs:144
Abp.Web.Localization.CurrentCultureSetter.SetCurrentCulture(HttpContext httpContext) in D:\Github\aspnetboilerplate\src\Abp.Web\Web\Localization\CurrentCultureSetter.cs:70
Abp.Dependency.IocResolverExtensions.Using(IIocResolver iocResolver, Action`1 action) in D:\Github\aspnetboilerplate\src\Abp\Dependency\IocResolverExtensions.cs:102
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +223
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +94
public static int GetTenantId(this IAbpSession session)
{
**if (!session.TenantId.HasValue)**
{
throw new AbpException("Session.TenantId is null! Possible problems: No user logged in or current logged in user in a host user (TenantId is always null for host users).");
}
return session.TenantId.Value;
}
I tried cleaning the cookies, but I get that exception before anything actually happens.
This is what invokes the code above: Castle.Proxies.SettingManagerProxy.GetSettingValue(String name) +182 Abp.Web.Localization.CurrentCultureSetter.GetDefaultCulture()
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
AbpSession.UserId is null right after login
Use(loginResult.User.TenantId, loginResult.User.Id)) { // AbpSession.TenantId and AbpSession.UserId now return the logged-in user's values. }.
Read more >get exception - Session.Tenant id is null #10501
Tenant id is null! Possible problems: No user logged in or current logged in user in a host user (Tenant id is always...
Read more >Articles Tutorials | AspNet Boilerplate
If both of UserId and TenantId is null, then current user is not logged in to the system. So, we can not know...
Read more >Explain the use of Session function in ABP framework- ...
Possible problems : No user logged in or current logged in user in a host user (TenantId is always null for host users).");...
Read more >Multi Tenancy | Documentation Center | ABP.IO
TenantId is nullable. When it is null that means the entity is owned by the Host side and not owned by a tenant....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can you please give us steps to reproduce it or share a project that reproduces the problem with using fresh template ?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.