Class ResponseHandlingConfig
- Namespace
- Ramstack.HtmxToolkit.Configuration
- Assembly
- Ramstack.HtmxToolkit.dll
Represents the response handling configuration for responses that match a specific HTTP status code pattern.
public sealed class ResponseHandlingConfig
- Inheritance
-
ResponseHandlingConfig
- Inherited Members
Examples
options.UseHtmxV2(config =>
{
// Assigning the list replaces the HTMX defaults, so the rules repeat them
// and add one more: swap validation forms returned with status 422.
config.ResponseHandling =
[
new() { Code = "204", Swap = false },
new() { Code = "[23]..", Swap = true },
new() { Code = "422", Swap = true, Error = false },
new() { Code = "[45]..", Swap = false, Error = true }
];
});
Properties
Code
Gets or sets the regular expression used to match response status codes.
public string? Code { get; set; }
Property Value
Error
Gets or sets a value indicating whether HTMX should treat this response as an error.
public bool? Error { get; set; }
Property Value
- bool?
IgnoreTitle
Gets or sets a value indicating whether HTMX should ignore <title> tags in the response.
public bool? IgnoreTitle { get; set; }
Property Value
- bool?
Select
Gets or sets a CSS selector used to select content from the response.
public string? Select { get; set; }
Property Value
Swap
Gets or sets a value indicating whether the response should be swapped into the DOM.
public bool? Swap { get; set; }
Property Value
- bool?
SwapOverride
Gets or sets an alternative swap style for the response.
[JsonIgnore]
public HtmxSwap? SwapOverride { get; set; }
Property Value
Remarks
Reads the style from SwapOverrideExpression, or returns null if the style is not recognized. Assigning a style replaces the complete expression, including any modifiers. Assigning null clears the override.
SwapOverrideExpression
Gets or sets the complete swap override expression, including any swap modifiers.
[JsonPropertyName("swapOverride")]
public string? SwapOverrideExpression { get; set; }
Property Value
Target
Gets or sets a CSS selector specifying an alternative target for the response.
public string? Target { get; set; }