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 f5ce191f20..f51223dcd5 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 @@ -26,7 +26,7 @@ public partial class LayoutHook : ComponentBase { layoutHooks = layoutHooks .Where(IsComponentBase) - .WhereIf(string.IsNullOrWhiteSpace(Layout), x => x.Layout == Layout) + .WhereIf(!string.IsNullOrWhiteSpace(Layout), x => 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 082ca59ee0..b4ea393fe7 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 @@ -16,10 +16,12 @@ public class LayoutHookViewComponent : AbpViewComponent Options = options.Value; } - public virtual IViewComponentResult Invoke(string name, string layout) + public virtual IViewComponentResult Invoke(string name, string? layout) { - var hooks = Options.Hooks.GetOrDefault(name)?.Where(x => x.Layout == layout && IsViewComponent(x)).ToArray() - ?? Array.Empty(); + var hooks = Options.Hooks.GetOrDefault(name)? + .Where(IsViewComponent) + .WhereIf(!string.IsNullOrWhiteSpace(layout), x => x.Layout == layout) + .ToArray() ?? Array.Empty(); return View( "~/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/Default.cshtml", 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 516c1234a0..d5c42a42cd 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) + string? layout = null) { return componentHelper.InvokeAsync( typeof(LayoutHookViewComponent),