Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Apr 28 11:46
    win32nipuh opened #105
  • Feb 27 20:48
    anthrax3 opened #104
  • Apr 15 2019 02:16
    project-orcon commented #96
  • Apr 08 2019 06:23
    MuratGOZCU closed #103
  • Apr 07 2019 21:13
    Marcel0024 commented #103
  • Jan 21 2019 07:26
    MuratGOZCU opened #103
  • Jan 21 2019 07:19
    MuratGOZCU closed #102
  • Jan 19 2019 22:48
    aldari closed #92
  • Jan 17 2019 04:22
    aceptra closed #53
  • Dec 12 2018 13:24
    MuratGOZCU edited #102
  • Dec 12 2018 13:24
    MuratGOZCU opened #102
  • Dec 05 2018 13:23
    chernihiv commented #96
  • Nov 07 2018 14:14
    flauberjp commented #96
  • Sep 18 2018 16:33
    grayniall commented #96
  • Aug 10 2018 18:46
    ani2479 opened #101
  • Jul 23 2018 16:24
    whizkidwwe1217 commented #88
  • Jul 17 2018 10:31
    whizkidwwe1217 opened #100
  • Jun 29 2018 07:53
    ovidiaconescu commented #96
  • May 21 2018 18:12
    TomBeckett commented #96
  • May 15 2018 20:47
    TomBeckett commented #96
Sindre Smistad
We have an API endpoint where we can't resolve the tenant by our usual way (is stored in JWT token), and we send the tenant id in as a part of the path /some/path/{tenantId}, and then have to resolve the tenant "manually" in the controller.
@whizkidwwe1217 I guess areas isn't very usable for limiting controllers to specific tenants?
@DownGoat I'm very new to the Saaskit software, I need to research the code for some time but will keep your issue in my mind while reading.
Sindre Smistad
@devJ0n Thanks, I'll post a reply if I get something working.
Sindre Smistad
@devJ0n Was able to create the right context like this:
[HttpGet("{id}/c", Name = "MediaGetFile")]
public async Task<IActionResult> GetFile(Guid id, [FromQuery] string tenantId)
    var tenantContext = await tenantResolver.ResolveAsyncExposed(tenantId);
    var dbContext = new SqlServerApplicationDbContext(context.Tenant);
    var media = dbContext.Medias.FirstOrDefault(m => m.Id == id);

    return File(media.Blob, media.Mime);
context.Tenant should be tenantContext.Tenant right?
Sindre Smistad
Sorry yes
Cool! Thx for sharing
Master Whiz
@devJ0n I haven't tried areas
But I'll take a look at it. Thanks
I also wonder how to handle situations where different tenants have different functionality requirements of services... For example if a service located in a specific controller is used by different tentants in different ways...
Sindre Smistad
Does anyone have a method for doing migrations during a deploy?
Is the app.UsePerTenant<AppTenant>( ) function still the one we should use when configuring security middleware?
Or have there been changes in ASP.NET Core 2.0
They are mentioning work been done in 2.0 aspnet/Security#1170 to support multitenancy
I can see this question has been asked before, but I can't see any answers to it: if I use the Caching AppTenantResolver and a property of the tenant changes, such as the tenant name, how do I remove the tenant from the cache and replace it with a new tenant instance reflecting the updated name?
Hello, how can I use the application with many tenants . For example:
http://localhost:60000" for tenant 1 , "http://localhost:60001" for tenant2, "http://localhost:60002" for tenant3
@benfoster Do you have any input? We can't use UsePerTenant in ASP.NET Core 2.0 anylonger....
At least not for the AddAuthentication().AddCookie(..).AddOpenIdConnect(...) middleware
Seems like this PR are about same issue: saaskit/saaskit#96
Sindre Smistad
@devJ0n We include a tenant id in our JWT token. The TenantResolver then looks for that claim.
@DownGoat Nice, we have a strange situation where users need to be able to access multiple tenants :smile: Have you managed to run one web application with different OIDC options or are all tenants running as same OIDC client?
Sindre Smistad
We don't use Open Id, we have our login users in a separate database which also has a table for tenants. We then load the settings for the tenants from this DB. You might consider creating different OIDC clients based on which tenant the user wants to access.
Josh Kerbaugh
@devJ0n Look at implementing IOptionsMonitor for the Authentication mechanism you are using and storing the relevant configuration options on each tenant.
public void ConfigureServices(IServiceCollection services)
services.AddSingleton<IOptionsMonitor<GoogleOptions>, GoogleOptionsSnapshot>();
//will now use GoogleOptionsSnapshot
public GoogleOptions CurrentValue => ResolveOptions(GoogleDefaults.AuthenticationScheme);
public GoogleOptions Get(string name) => ResolveOptions(name);

private GoogleOptions ResolveOptions(string scheme)
            var tenant = mHttpContextAccessor.HttpContext.GetTenant<SiteInfo>();

            var options = new GoogleOptions{
                ClientId = "",
                ClientSecret = ""   

            //Code to configure options.StateDataFormat and options.Backchannel omitted for brevity

            //Grab configuration from Tenant information loaded from the dbcontext
            if (!string.IsNullOrWhiteSpace(tenant?.ClientId))
                options.ClientId = tenant.ClientId;
                options.ClientSecret = tenant.ClientSecret;
                options.SignInScheme = IdentityConstants.ExternalScheme;
                options.AccessType = "offline";
                options.SaveTokens = true;

                foreach (var scope in tenant.Scopes)

            return options;

@jkerb135 Thank you! Where is the ResolveOptions method located, is it in the Startup.cs file?
Or is is a concrete class named "GoogleOptionsSnapshot" which implements the IOptionsMonitor interface
Josh Kerbaugh
@devJ0n it would be a concrete class that implements the IOptionsMonitor interface
Madhu Babu
Hi, am developing a single page SaaS application (Angular 5, WebAPI 2) can you help how to implement multitenancy in this approach
Hi All,
I am using multi tenancy with multi database.
  1. Master DB
2 TenantDB - 1
3 TenantDB -2
I have successfully mapped all the tenant with Host and also successfully able to call all the existing different tenant databases.
My question is support i am logged with MasterDB - host : localhost:9000 and i want to access all the data of TenantDB - 1(host : localhost:9001) and TenantDB-2 (host: localhost:9002) when i am logged in with the MasterDB.
Please let me know how do i achieve this as the tenant context is already binded with MasterDB database.
I am trying to built a multi tenant application with separate database for each tenant. Can any one help me how do I configure dbcontext based on tenant.
I'm running two ASP.NET Core MVC webb apps on my localhost and both applications is using cookies. Should CookieDomain separation of cookies be working if I specify custom domain names in my hosts file?
Hi guys (and girls), does NLog.Web have support for .NET Standard?
It seems it doesn't have support, so what to do?
I have a class library using .NET standard library 2.0 which have a type inheriting the AspNetLayoutMultiValueRendererBase
Eric Gitonga Njue

Maybe this question has been answered, if so I would appreciate a link to it.
I want to load the tenants from a Db & create their respective databases (Each tenant to have their own database). I've tried overriding my DbContext onConfiguring but tenant is always null. See below code,

` public class CounterServeDefaultDbContext : DbContext
private readonly AppTenant tenant;

    public CounterServeDefaultDbContext(AppTenant tenant)
        this.tenant = tenant;

    #region DbSets

    public DbSet<AppTenantTuple> AppTenants { get; set; }


    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
} `

StartUp Class

` public void ConfigureServices(IServiceCollection services)
services.AddMultitenancy<AppTenant, AppTenantResolver>();


        // AddAuthentication adds the authentication services to DI and configures "Bearer" as the default scheme
            // AddIdentityServerAuthentication adds the IdentityServer access token validation handler into DI for use by the authentication services
            .AddIdentityServerAuthentication(options =>
                options.Authority = AUTHORITY;
                options.RequireHttpsMetadata = false;
                options.ApiName = "***";


        services.AddSingleton<IConfigureOptions<MultitenancyOptions>, ConfigureMultitenancyOptions>();

        // services.Configure<MultitenancyOptions>(Configuration.GetSection("Multitenancy"));

Just wondering if anyone has had success getting a saaskit Multi-Tenant app working in Azure using subdomains. if so, any pointers?
@EssentialAgility sure, using custom domains. Where did u get stuck?