diff --git a/src/OrchardCore.Modules/OrchardCore.Tenants/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Tenants/Controllers/AdminController.cs index 570f43b1afb..11fd53be527 100644 --- a/src/OrchardCore.Modules/OrchardCore.Tenants/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Tenants/Controllers/AdminController.cs @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc.Localization; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using OrchardCore.Data; using OrchardCore.DisplayManagement; @@ -37,7 +38,6 @@ public class AdminController : Controller private readonly IDataProtectionProvider _dataProtectorProvider; private readonly IClock _clock; private readonly INotifier _notifier; - private readonly ISiteService _siteService; private readonly ITenantValidator _tenantValidator; private readonly dynamic New; @@ -55,7 +55,6 @@ public AdminController( IDataProtectionProvider dataProtectorProvider, IClock clock, INotifier notifier, - ISiteService siteService, ITenantValidator tenantValidator, IShapeFactory shapeFactory, IStringLocalizer stringLocalizer, @@ -71,7 +70,6 @@ public AdminController( _dataProtectorProvider = dataProtectorProvider; _clock = clock; _notifier = notifier; - _siteService = siteService; _tenantValidator = tenantValidator; New = shapeFactory; @@ -94,8 +92,15 @@ public async Task Index(TenantIndexOptions options, PagerParamete var allSettings = _shellHost.GetAllSettings().OrderBy(s => s.Name); var dataProtector = _dataProtectorProvider.CreateProtector("Tokens").ToTimeLimitedDataProtector(); - var siteSettings = await _siteService.GetSiteSettingsAsync(); - var pager = new Pager(pagerParameters, siteSettings.PageSize); + var pageSize = 10; + var siteService = HttpContext.RequestServices.GetService(); + if (siteService != null) + { + var siteSettings = await siteService.GetSiteSettingsAsync(); + pageSize = siteSettings.PageSize; + } + + var pager = new Pager(pagerParameters, pageSize); var entries = allSettings.Select(x => { diff --git a/src/OrchardCore.Modules/OrchardCore.Tenants/Controllers/FeatureProfilesController.cs b/src/OrchardCore.Modules/OrchardCore.Tenants/Controllers/FeatureProfilesController.cs index c66e14cb2ef..b278cae14af 100644 --- a/src/OrchardCore.Modules/OrchardCore.Tenants/Controllers/FeatureProfilesController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Tenants/Controllers/FeatureProfilesController.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc.Localization; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using Newtonsoft.Json; using OrchardCore.Admin; @@ -28,7 +29,6 @@ public class FeatureProfilesController : Controller { private readonly IAuthorizationService _authorizationService; private readonly FeatureProfilesManager _featureProfilesManager; - private readonly ISiteService _siteService; private readonly INotifier _notifier; private readonly IStringLocalizer S; private readonly IHtmlLocalizer H; @@ -37,7 +37,6 @@ public class FeatureProfilesController : Controller public FeatureProfilesController( IAuthorizationService authorizationService, FeatureProfilesManager featueProfilesManager, - ISiteService siteService, INotifier notifier, IShapeFactory shapeFactory, IStringLocalizer stringLocalizer, @@ -46,7 +45,6 @@ IHtmlLocalizer htmlLocalizer { _authorizationService = authorizationService; _featureProfilesManager = featueProfilesManager; - _siteService = siteService; _notifier = notifier; New = shapeFactory; S = stringLocalizer; @@ -60,8 +58,15 @@ public async Task Index(ContentOptions options, PagerParameters p return Forbid(); } - var siteSettings = await _siteService.GetSiteSettingsAsync(); - var pager = new Pager(pagerParameters, siteSettings.PageSize); + var pageSize = 10; + var siteService = HttpContext.RequestServices.GetService(); + if (siteService != null) + { + var siteSettings = await siteService.GetSiteSettingsAsync(); + pageSize = siteSettings.PageSize; + } + + var pager = new Pager(pagerParameters, pageSize); var featureProfilesDocument = await _featureProfilesManager.GetFeatureProfilesDocumentAsync(); var featureProfiles = featureProfilesDocument.FeatureProfiles.ToList();