AppSurface Search
API Reference

Forms

Type

RazorWireFormFields

Source

Defines stable hidden field names used by RazorWire-enhanced form submissions.

Type

RazorWireFormRequestClassifier

Source

Detects whether an incoming request originated from a RazorWire-enhanced form.

Method

IsRazorWireFormRequestAsync

ValueTask<bool> IsRazorWireFormRequestAsync(HttpRequest request, CancellationToken cancellationToken = default)

Determines whether a request carries RazorWire form markers.

Parameters

  • request
    The HTTP request to inspect.
  • cancellationToken
    Token used when fallback URL-encoded form parsing is required.

Returns

true when the request has the RazorWire form header, an already-parsed marker field, or a safely readable URL-encoded marker field; otherwise false .

Type

RazorWireEventIds

Source

Defines stable event identifiers for RazorWire form-related logs.

Type

RazorWireFormFailureTarget

Source

Normalizes form failure targets that can be addressed safely by server-generated Turbo Streams.

Method

TryNormalizeIdTarget

bool TryNormalizeIdTarget(string? failureTarget, out string normalized)

Attempts to normalize a simple element-id target for a failed RazorWire form.

Parameters

  • failureTarget
    The value supplied by data-rw-form-failure-target . A leading # is accepted and removed.
  • normalized
    When this method returns true , contains the id without a leading # .

Returns

true when failureTarget is a non-empty element id; otherwise false . CSS selector-like values that start with . or [ , and values containing whitespace, are rejected because server-generated Turbo Stream target attributes address one element id rather than arbitrary selectors.

Type

RazorWireFormHeaders

Source

Defines stable HTTP header names used by RazorWire-enhanced form submissions.

Type

RazorWireAntiforgeryFailureFilter

Source

Converts RazorWire form anti-forgery validation failures into negotiated responses and preserves local fallback.

Remarks

The filter runs late in MVC result execution so it can see IAntiforgeryValidationFailedResult results produced by MVC anti-forgery validation. It only rewrites requests classified as RazorWire forms, sets RazorWireFormHeaders.FormHandled , and chooses Turbo Stream, HTML, or plain-text output from the request's Accept header. Turbo Stream responses prefer a form-local target when the posted marker can be read within the configured safety limit; otherwise they append one safe diagnostic block to body . Correlated Turbo responses echo request metadata so a delayed form-local failure cannot update a newer dialog flow. Invalid presentation metadata returns the same 400 diagnostic as plain text without applying stream actions, with RazorWireFormHeaders.FormHandled false so the current form can present local failure/retry UI.

Method

OnResultExecutionAsync

Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)

Rewrites RazorWire anti-forgery validation failures into form responses, then continues result execution. Invalid presentation metadata uses an unhandled plaintext response so the current form can show local retry UI.

Parameters

  • context
    The MVC result-executing context.
  • next
    Delegate that continues MVC result execution.

Returns

A task that completes when the result pipeline has continued.

Property

Order

int Order { get; } Source

Gets the filter order. The value runs after normal MVC result filters while still leaving a small buffer for application filters that intentionally need to run later.