Skip to content

http: apply [HtmxResponse] headers before the action runs - #116

Merged
rameel merged 2 commits into
mainfrom
http/htmx-response-before-action
Oct 29, 2026
Merged

rameel merged 2 commits into
mainfrom
http/htmx-response-before-action

Conversation

@rameel

@rameel rameel commented Oct 29, 2026

Copy link
Copy Markdown
Owner
  • HtmxResponseAttribute now implements IActionFilter and IPageFilter instead of IResultFilter and sets its headers before the action or page handler runs.
  • Values set in code with Response.Htmx(...) or Response.GetHtmxHeaders() now take precedence, and code can remove a header that the attribute set. The action's attribute still wins over the controller's.

The attribute set its headers in OnResultExecuting, after the action
had run, so it replaced the values that the action set in code, such
as a Response.Htmx(htmx => htmx.Retarget(...)) call for validation
errors. Code inside the action is more specific than an attribute, in
the same way that an action's attribute already wins over the
controller's.

The attribute is now an action filter and a page filter, and sets the
headers before the action or page handler runs. The code can replace or
remove them, and the action's attribute still wins over the
controller's.
@rameel
rameel merged commit d0f77f8 into main Oct 29, 2026
1 check passed
@rameel
rameel deleted the http/htmx-response-before-action branch October 29, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant