The sample multi-tenancy project (MultiTenantApplication.csproj) works fine with razor pages but how should we enable controllers and views?
Trying to add them by adding
builder.Services.AddControllersWithViews();
...
app.MapDefaultControllerRoute();
results in the error:
ArgumentException: Value cannot be null or empty. (Parameter 'areaName')
if instead of MapDefaultControllerRoute() I use endpoints like this:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute("MyDefaultRoute", "{controller=Home}/{action=Index}");
});
It works fine, but when I want to use DI to inject shell settings as in the razor pages sample in the index view
@inject ShellSettings settings
And use constructor injection
public class MessageController : Controller
{
private readonly ShellSettings _settings;
public MessageController(ShellSettings settings)
{
_settings = settings;
}
}
I get the error:
InvalidOperationException: Unable to resolve service for type 'OrchardCore.Environment.Shell.ShellSettings' while attempting to activate 'MultiTenantApplication.Controllers.MessageController'.
The sample multi-tenancy project (MultiTenantApplication.csproj) works fine with razor pages but how should we enable controllers and views?
Trying to add them by adding
results in the error:
if instead of MapDefaultControllerRoute() I use endpoints like this:
It works fine, but when I want to use DI to inject shell settings as in the razor pages sample in the index view
And use constructor injection
I get the error: