Table of Contents

Struct HtmxResponseHeaders

Namespace
Ramstack.HtmxToolkit
Assembly
Ramstack.HtmxToolkit.dll

Represents strongly typed HTMX response headers.

public readonly struct HtmxResponseHeaders
Inherited Members

Properties

Location

Gets or sets the value of the HX-Location header, which performs a client-side redirect without a full-page reload.

[MaybeNull]
public string Location { get; set; }

Property Value

string

PushUrl

Gets or sets the value of the HX-Push-Url header, which pushes a new URL onto the browser's history stack.

[MaybeNull]
public string PushUrl { get; set; }

Property Value

string

Remarks

Unlike PushUrl(string), setting this property does not remove the HX-Replace-Url header.

Redirect

Gets or sets the value of the HX-Redirect header, which performs a client-side redirect with a full-page reload.

[MaybeNull]
public string Redirect { get; set; }

Property Value

string

Refresh

Gets or sets a value indicating whether the HX-Refresh header requests a full-page refresh.

public bool Refresh { get; set; }

Property Value

bool

ReplaceUrl

Gets or sets the value of the HX-Replace-Url header, which replaces the current URL without pushing a new entry to the browser's history stack.

[MaybeNull]
public string ReplaceUrl { get; set; }

Property Value

string

Remarks

Unlike ReplaceUrl(string), setting this property does not remove the HX-Push-Url header.

Reselect

Gets or sets the CSS selector specified by the HX-Reselect header to determine which part of the response is swapped in.

[MaybeNull]
public string Reselect { get; set; }

Property Value

string

Reswap

Gets or sets the swap style specified by the HX-Reswap header.

[DisallowNull]
public HtmxSwap? Reswap { get; set; }

Property Value

HtmxSwap?

ReswapExpression

Gets or sets the complete HX-Reswap header value, including any swap modifiers.

[MaybeNull]
public string ReswapExpression { get; set; }

Property Value

string

Retarget

Gets or sets the CSS selector specified by the HX-Retarget header to change the target of the content update.

[MaybeNull]
public string Retarget { get; set; }

Property Value

string

Trigger

Gets the client-side events to trigger through the HX-Trigger header.

public IReadOnlyList<KeyValuePair<string, string>>? Trigger { get; }

Property Value

IReadOnlyList<KeyValuePair<string, string>>

Remarks

Each entry pairs an event name with its detail serialized as JSON. Events are listed in the order they were added, including repeated names. The list is a read-only live view of the events accumulated for the current response, which are written into the header immediately before the response starts. If no events have been added, the property returns null.

HTMX 1.x and 2.x trigger these events when the response is received, whereas HTMX 4.x triggers them when the request completes (after the swap whenever one is performed).

TriggerAfterSettle

Gets the client-side events to trigger through the HX-Trigger-After-Settle header after the settle step.

public IReadOnlyList<KeyValuePair<string, string>>? TriggerAfterSettle { get; }

Property Value

IReadOnlyList<KeyValuePair<string, string>>

Remarks

Each entry pairs an event name with its detail serialized as JSON. Events are listed in the order they were added, including repeated names. The list is a read-only live view of the events accumulated for the current response, which are written into the header immediately before the response starts. If no events have been added, the property returns null.

In HTMX 4.x, assigned events are accumulated in Trigger and emitted through HX-Trigger when the request completes (after the swap whenever one is performed); the requested after-settle timing cannot be preserved.

TriggerAfterSwap

Gets the client-side events to trigger through the HX-Trigger-After-Swap header after the swap step.

public IReadOnlyList<KeyValuePair<string, string>>? TriggerAfterSwap { get; }

Property Value

IReadOnlyList<KeyValuePair<string, string>>

Remarks

Each entry pairs an event name with its detail serialized as JSON. Events are listed in the order they were added, including repeated names. The list is a read-only live view of the events accumulated for the current response, which are written into the header immediately before the response starts. If no events have been added, the property returns null.

In HTMX 4.x, assigned events are accumulated in Trigger and emitted through HX-Trigger when the request completes (after the swap whenever one is performed).