RazorDocs Search
API Reference

Forms

Type

RazorWireEventIds

Source

Defines stable event identifiers for RazorWire form-related logs.

Type

RazorWireFormHeaders

Source

Defines stable HTTP header 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) Source

Determines whether a request carries RazorWire form markers.

Parameters

  • requestThe HTTP request to inspect.
  • cancellationTokenToken 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

RazorWireFormFields

Source

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

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) Source

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

Parameters

  • failureTargetThe value supplied by data-rw-form-failure-target. A leading # is accepted and removed.
  • normalizedWhen 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

RazorWireAntiforgeryFailureFilter

Source

Converts RazorWire form anti-forgery validation failures into handled responses that Turbo can render in-place.

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.

Method

OnResultExecutionAsync

Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next) Source

Rewrites RazorWire anti-forgery validation failures into handled form responses, then continues result execution.

Parameters

  • contextThe MVC result-executing context.
  • nextDelegate 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.