DEV Community

Multi-Tenant Applications with ASP.NET Core 2.2 - Getting Started

Andrew Grothe on August 17, 2019

As software as a service has been more ubiquitous, multi-tenancy has become a basic requirement of most web applications. This series will outline ...
Collapse
 
garethdebruyn profile image
garethdebruyn

Thanks Andrew, this has really helped. Im trying to implement this in .net core 3.1.2
I get an error that says Const does not exist in the current context. What am I missing?

_httpContextAccessor.HttpContext.Items.TryGetValue(Const.CURRENT_TENANT, out object currentTenant);

Collapse
 
agrothe profile image
Andrew Grothe

Hi Gareth, Const is a class I used to keep my constants. Just replace Const.CURRENT_TENANT with "Current_Tenant" or any other string you which to use as a key in the HttpContext.Items dictionary. Updating this to .NET Core 3 is on my list of things to do.

Collapse
 
tmakaro profile image
Troy Makaro

Have you done the next post yet?

"In the next post we will modify our Login method to ensure the current user has access to the current domain by using Claims."

Collapse
 
agrothe profile image
Andrew Grothe

I have not, however, I'll be updating it to Core 3.1 soon and writing the next part.

Collapse
 
galdin profile image
Galdin Raphael

Short and sweet indeed. Thanks for sharing. I find the mention of the hosts file interesting, I've always stayed away from it but I guess I'm ready to give it a shot now :D

Collapse
 
agrothe profile image
Andrew Grothe

I like using the hosts file for development. Especially when building new WordPress sites. I can point a domain at the new site even before DNS propagates and get started on development right away.

Collapse
 
scara1701 profile image
Gwen Demulder

Looking forward to the next part of the article.
Thanks for this starter!

Collapse
 
rodrigojuarez profile image
Rodrigo Juarez

Hey Andrew, really helpful post!

Any suggestion about how to get the tenant if I use something like

domain.com/tenant1
domain.com/tenant2

Collapse
 
bbaldallaque profile image
Bryant Baldallaque

Buenas, cuando saldra
Hello, when will the second part come out, and when will I migrate to use 3.1

Collapse
 
agrothe profile image
Andrew Grothe

Updated the original to include the DI part mentioned at the end. It was simple enough it didn't warrant a post of its own.

Collapse
 
mokenyon profile image
Morgan Kenyon

Great article! Looking forward to your next article!