Open Closed

remove tenant from header request #4843


User avatar
0
ElifKaya created

Hi,

I want to remove tenant from header request after I navigate to other page as click just Documents Menu Item. How can I do this?

Thanks

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v5.3.3
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

4 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Do you want to switch to host when navigating the document page, right?

  • User Avatar
    0
    ElifKaya created

    Hi,

    Do you want to switch to host when navigating the document page, right?

    Yes, I want to use host db when navigate to documents page even I login with tenant user

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can check this: https://docs.abp.io/en/abp/latest/Multi-Tenancy#custom-tenant-resolvers

    Pseudo code:

    public class DocumentTenantResolverContributor : HttpTenantResolveContributorBase
    {
        public override string Name { get; }
        protected override Task<string> GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext)
        {
            if(httpContext.Request.GetDisplayUrl().Contains("/..."))
            {
                context.Handled = true;
            }
            
            return Task.FromResult<string>(null);
        }
    }
    
    Configure<AbpTenantResolveOptions>(options =>
    {
        options.TenantResolvers.Insert(0, .);
    });
    

    The TenantResolverContributor needs add to as the first contributor

  • User Avatar
    0
    ElifKaya created

    it works, thanks

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11