Table of Contents

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 INavProvider

The navigation provider for building updated navigation content.

viewPaths ViewPaths

The 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 NavActionAttribute

The NavActionAttribute instance containing the view name.

cad ControllerActionDescriptor

The controller action descriptor.

Returns

Task<string>

A task containing the view name, or null if no specific view is configured.

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 NavActionAttribute

The NavActionAttribute that triggered this filter.

multiSwapViewResult MultiSwapViewResult

The MultiSwapViewResult to update with navigation and content.

context ResultExecutingContext

The result executing context.

Returns

Task

A task representing the asynchronous update operation.

Exceptions

InvalidOperationException

Thrown when the MultiSwapViewResult has no model set.