Class NavActionResultFilter
- Namespace
- Htmx.Components.NavBar.Internal
- Assembly
- Htmx.Components.dll
A result filter that processes controller actions marked with NavActionAttribute to provide navigation-aware responses. This filter updates the navigation bar and renders the appropriate content based on whether the request is an HTMX request or a full page request.
public class NavActionResultFilter : OobResultFilterBase<NavActionAttribute>, IAsyncResultFilter, IFilterMetadata
- Inheritance
-
NavActionResultFilter
- Implements
- Inherited Members
- Extension Methods
Remarks
For HTMX requests, this filter performs out-of-band updates to refresh the navigation bar and renders the action's content in the configured view. For non-HTMX requests, it renders the full page using the view specified in the NavActionAttribute.
Constructors
NavActionResultFilter(INavProvider, ViewPaths)
Initializes a new instance of the NavActionResultFilter class.
public NavActionResultFilter(INavProvider navProvider, ViewPaths viewPaths)
Parameters
navProvider
INavProviderThe navigation provider for building updated navigation content.
viewPaths
ViewPathsThe view paths configuration for resolving view names.
Methods
GetViewNameForNonHtmxRequest(NavActionAttribute, ControllerActionDescriptor)
Gets the view name to render for non-HTMX requests. Returns the view name specified in the NavActionAttribute, or null if not specified.
protected override Task<string?> GetViewNameForNonHtmxRequest(NavActionAttribute attribute, ControllerActionDescriptor cad)
Parameters
attribute
NavActionAttributeThe NavActionAttribute instance containing the view name.
cad
ControllerActionDescriptorThe controller action descriptor.
Returns
UpdateMultiSwapViewResultAsync(NavActionAttribute, MultiSwapViewResult, ResultExecutingContext)
Updates the MultiSwapViewResult with refreshed navigation content and the action's result. This method performs out-of-band updates for the navigation bar and renders the action content in the specified view or the default navigation content view.
protected override Task UpdateMultiSwapViewResultAsync(NavActionAttribute attribute, MultiSwapViewResult multiSwapViewResult, ResultExecutingContext context)
Parameters
attribute
NavActionAttributeThe NavActionAttribute that triggered this filter.
multiSwapViewResult
MultiSwapViewResultThe MultiSwapViewResult to update with navigation and content.
context
ResultExecutingContextThe result executing context.
Returns
- Task
A task representing the asynchronous update operation.
Exceptions
- InvalidOperationException
Thrown when the MultiSwapViewResult has no model set.