Class HtmxResponseAttribute
- Namespace
- Ramstack.HtmxToolkit
- Assembly
- Ramstack.HtmxToolkit.dll
Specifies HTMX response headers to apply when an action result is executed for an HTMX request.
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public sealed class HtmxResponseAttribute : Attribute, IResultFilter, IFilterMetadata
- Inheritance
-
HtmxResponseAttribute
- Implements
- Inherited Members
Examples
[HttpGet("/inventory/{sku}")]
[HtmxRequest]
[HtmxResponse(Retarget = "#inventory-status", Reswap = HtmxSwap.OuterHtml)]
public IActionResult Inventory(string sku) =>
PartialView("_Inventory", inventory.Find(sku));
Properties
Refresh
Gets or sets a value indicating whether the HX-Refresh header is set
to request a full-page refresh.
public bool Refresh { get; set; }
Property Value
Reselect
Gets or sets the CSS selector to specify in the HX-Reselect header.
[MaybeNull]
public string Reselect { get; set; }
Property Value
Reswap
Gets or sets the swap style to specify in the HX-Reswap header.
public HtmxSwap Reswap { get; set; }
Property Value
ReswapExpression
Gets or sets the complete HX-Reswap header value, including any swap modifiers.
[MaybeNull]
public string ReswapExpression { get; set; }
Property Value
Retarget
Gets or sets the CSS selector to specify in the HX-Retarget header.
[MaybeNull]
public string Retarget { get; set; }
Property Value
Methods
OnResultExecuted(ResultExecutedContext)
Called after the action result executes.
public void OnResultExecuted(ResultExecutedContext context)
Parameters
contextResultExecutedContext
OnResultExecuting(ResultExecutingContext)
Called before the action result executes.
public void OnResultExecuting(ResultExecutingContext context)
Parameters
contextResultExecutingContext