aspnetboilerplate: 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 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: TenentID

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()

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Can you please give us steps to reproduce it or share a project that reproduces the problem with using fresh template ?