Open Closed

Switching-Tenants-when-switching-tenants-the-cookie-is-retrieving-the-deleted-tenant-ID-with-the-same-tenant-name #6826


User avatar
0
vipulbuoyancy created
  • ABP Framework version: v7.4.0
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I deleted the tenant and created it again with the same name, I added the admin and another user to the new one, but when clicking switch tenant and entering the name, the tenant_ID that is retrieved in the cookie is the one of the deleted account which doesn’t have the employees trying to login it won’t allow them to login. I tried clearing cookies, force refresh, didn’t help, once you enter the tenant name, it retrieved the ID of the deleted one.

I try this code but it's not work

Configure<AbpAspNetCoreMultiTenancyOptions>(options =>
{
    options.MultiTenancyMiddlewareErrorPageBuilder = async (httpContext, exception) =>
    {
        foreach (var cookie in httpContext.Request.Cookies)
        {
            httpContext.Response.Cookies.Delete(cookie.Key);
        }
        httpContext.Response.Redirect(httpContext.Request.Path);
        return true;
    };
});

Please help to resolve this.

Thanks

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

5 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Could you share the full steps to reproduce the problem? thanks.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    vipulbuoyancy created

    Hi,

    Thank you for support. I shared steps to reproduce:

    • I created new tenant "ABCD" and login with default tenant's admin
    • I deleted the tenant "ABCD" and re-create new tenant with same name "ABCD"
    • I try to login with tenant "ABCD" but when clicking switch tenant and entering the name, the tenant_ID that is retrieved in the cookie is the one of the deleted account which doesn’t have the users trying to login it won’t allow them to login

    Thank you

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    It works for me:

    You can see the video https://drive.google.com/file/d/10APitqORLwtrMYb7MAo4J8W-XWsMmxYg/view?usp=sharing

    Configure<AbpAspNetCoreMultiTenancyOptions>(options =>
    {
        options.MultiTenancyMiddlewareErrorPageBuilder = async (httpContext, exception) =>
        {
            foreach (var cookie in httpContext.Request.Cookies)
            {
                httpContext.Response.Cookies.Delete(cookie.Key);
            }
            httpContext.Response.Redirect(httpContext.Request.GetEncodedPathAndQuery());
            return true;
        };
    });
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    vipulbuoyancy created

    Hi

    It's not working for me this code

    Configure<AbpAspNetCoreMultiTenancyOptions>(options =>
    {
        options.MultiTenancyMiddlewareErrorPageBuilder = async (httpContext, exception) =>
        {
            foreach (var cookie in httpContext.Request.Cookies)
            {
                httpContext.Response.Cookies.Delete(cookie.Key);
            }
            httpContext.Response.Redirect(httpContext.Request.GetEncodedPathAndQuery());
            return true;
        };
    });
    

    I have follow all steps from your video. thank you

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Could you share a simple project via email that can reproduce the problem with me? I will check it. shiwei.liang@volosoft.com

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 23, 2026, 09:57
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.