Class PageStateOobInjectorFilter
- Namespace
- Htmx.Components.Filters
- Assembly
- Htmx.Components.dll
A result filter that automatically injects updated page state into HTMX responses when the page state has been modified during request processing. This filter ensures that page state changes are persisted in the client browser for subsequent HTMX requests.
public class PageStateOobInjectorFilter : IAsyncResultFilter, IFilterMetadata
- Inheritance
-
PageStateOobInjectorFilter
- Implements
- Inherited Members
- Extension Methods
Remarks
This filter only operates on MultiSwapViewResult instances and only when the page state is marked as dirty (has been modified). When triggered, it adds an out-of-band update that replaces the page state hidden input field with the updated encrypted state data.
Constructors
PageStateOobInjectorFilter(IPageState)
Initializes a new instance of the PageStateOobInjectorFilter class.
public PageStateOobInjectorFilter(IPageState pageState)
Parameters
pageState
IPageStateThe page state service that tracks state modifications.
Methods
OnResultExecutionAsync(ResultExecutingContext, ResultExecutionDelegate)
Executes the filter logic, injecting page state updates when necessary. The filter checks if the result is a MultiSwapViewResult and if the page state has been modified, then adds an out-of-band update for the page state container.
public Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
Parameters
context
ResultExecutingContextThe result executing context.
next
ResultExecutionDelegateThe next filter in the pipeline.
Returns
- Task
A task representing the asynchronous filter operation.