asp.net-mvcmulti-tenantorchardcore

Multi-tenancy using orchardcore and mvc


I'm trying to add multi-tenancy functionality to an existing aps.net web application using orchard core. I followed the steps described here and this sample. The sample works fine with the razor pages but not the way I expect with MVC.

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddOrchardCore().AddMvc().WithTenants();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}
else
{
    app.UseExceptionHandler("/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseOrchardCore();

app.Run();

What I expect is calling .AddMvc() and .UseOrchardCore() enable using MVC as it does with razor pages, Shouldn't I? How can I make it work with Controllers and Views?


Solution

  • Turns out the orchardcore way of doing this is by using modules or features as discussed here.

    So finally I created a Main module and a separate project for multi-tenancy and added the main module as a feature to every tenant.