Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8905617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:26:25+00:00 2026-06-15T02:26:25+00:00

I started working with autofac’s multitenancy integration and I have a question: Can I

  • 0

I started working with autofac’s multitenancy integration and I have a question:
Can I add a controller that’s only available for an specific tenant?
I know that you can override a controller registered in the base container, but I want a controller that is only available for the tenant that registered?
Is that possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:26:26+00:00Added an answer on June 15, 2026 at 2:26 am

    While I haven’t tried it, I believe you could do that with a little manual registration.

    The problem is, if you auto-register all the controllers in the main container using builder.RegisterControllers(theAssembly) then all the controllers will automatically be picked up – including the tenant-specific one. (Assuming the tenant-specific one is in the assembly with everything else.)

    To make it easy on yourself, you might want to split the tenant-specific stuff into a separate assembly. Then to get controllers that are only for one tenant, it’d be something like this:

    var builder = new ContainerBuilder();
    builder.RegisterControllers(commonControllerAssembly);
    var appContainer = builder.Build();
    var tenantStrategy = new MyTenantIdentificationStrategy();
    var mtc = new MultitenantContainer(tenantStrategy, appContainer);
    
    // Register the tenant-specific stuff when you configure the tenant.
    mtc.ConfigureTenant(
      "tenant-1",
      b => b.RegisterControllers(tenantControllerAssembly));
    
    // And don't forget to set the resolver.
    DependencyResolver.SetResolver(new AutofacDependencyResolver(mtc));
    

    Just like any other tenant-specific dependency.

    When MVC tries to resolve an instance of your controller, it does it from the DependencyResolver, which will behave in a multitenant fashion and only be able to resolve the controller when the right tenant is making the request. If some other tenant makes a request for that controller, the controller won’t be found in the list of registered components so they’ll get an error.

    Note that if you put your controller in a separate assembly that isn’t referenced by the main application assembly, you may also need to tell the ASP.NET compilation system about it or the controller type won’t be found properly. Add it to the system.web/compilation/assemblies list:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.web>
            <compilation>
                <assemblies>
                    <add assembly="The.Name.Of.Your.Assembly.Here" />
                </assemblies>
            </compilation>
        </system.web>
    </configuration>
    

    But, like I said, I haven’t tried it. I’ve only ever done controller overrides.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently started working with pointers and have created a little script that is supposed
I have recently started working on a very large C++ project that, after completing
I have started working with Hadoop recently. There is table named Checkout that I
I have recently started working with Android. I don't have that much experience with
Started working on a new application this week that is running the latest rails
Ive started working on a product that uses license files. These files need to
I've just started working with Propel and I love it, but I have a
I started working on same project recently and I have noticed some strange problem
I started working on an experimental project tonight. I've realized that I need to
I started working with php and mysql today. Basically, what I have, is an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.