diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs index f51223dcd5..2930303efd 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs @@ -25,8 +25,7 @@ public partial class LayoutHook : ComponentBase if (LayoutHookOptions.Value.Hooks.TryGetValue(Name, out var layoutHooks)) { layoutHooks = layoutHooks - .Where(IsComponentBase) - .WhereIf(!string.IsNullOrWhiteSpace(Layout), x => x.Layout == Layout) + .Where(x => IsComponentBase(x) && (string.IsNullOrWhiteSpace(x.Layout) || x.Layout == Layout)) .ToList(); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.cs index b4ea393fe7..0ab4235c59 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.cs @@ -19,8 +19,7 @@ public class LayoutHookViewComponent : AbpViewComponent public virtual IViewComponentResult Invoke(string name, string? layout) { var hooks = Options.Hooks.GetOrDefault(name)? - .Where(IsViewComponent) - .WhereIf(!string.IsNullOrWhiteSpace(layout), x => x.Layout == layout) + .Where(x => IsViewComponent(x) && (string.IsNullOrWhiteSpace(x.Layout) || x.Layout == layout)) .ToArray() ?? Array.Empty(); return View( diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/ViewComponentHelperLayoutHookExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/ViewComponentHelperLayoutHookExtensions.cs index d5c42a42cd..516c1234a0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/ViewComponentHelperLayoutHookExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/ViewComponentHelperLayoutHookExtensions.cs @@ -9,7 +9,7 @@ public static class ViewComponentHelperLayoutHookExtensions public static Task InvokeLayoutHookAsync( this IViewComponentHelper componentHelper, string name, - string? layout = null) + string layout) { return componentHelper.InvokeAsync( typeof(LayoutHookViewComponent),