ViewContext ViewContext { get; set; }
Source
Gets or sets the view context.
Tag helper for rendering the necessary RazorWire scripts and dialog stylesheet.
void Process(TagHelperContext context, TagHelperOutput output)
Renders the client-side script tags required by RazorWire and removes the wrapper element so no enclosing tag is emitted.
context
output
InvalidOperationException
RazorWireOptions.Hybrid
. RazorWireHybridOptions.LiveOrigin
is not an absolute HTTP(S) origin or includes a path, query string, fragment, or userinfo. Also thrown when RazorWireTurboOptions.RuntimeMode
contains an undefined value, or when custom mode has a missing or invalid RazorWireTurboOptions.CustomPath
. Normal dependency injection validates these values at startup; the renderer repeats the checks for callers that construct it directly.
The generated runtime script includes data attributes for form failure UX and loading feedback, development diagnostics, split-origin live origin, hybrid credential behavior, and the lazy anti-forgery token endpoint. The helper normalizes RazorWireFormOptions.Loading
into data-rw-form-loading-enabled
, data-rw-form-loading-show-fallback-bar
, and data-rw-form-loading-prevent-duplicate-submissions
attributes on the RazorWire runtime script. When RazorWireFormLoadingOptions.Enabled
is enabled, the stylesheet is emitted as a versioned link at /_content/ForgeTrust.RazorWire/razorwire/razorwire.loading.css
under the current request path base; its visual rules are external so the fallback remains compatible with a strict style-src policy. The helper normalizes RazorWireOptions.Hybrid
. RazorWireHybridOptions.LiveOrigin
before emitting it so the browser receives only an origin, never a path-bearing URL. The anti-forgery endpoint is emitted relative to the current request path base so applications mounted under a virtual directory refresh tokens from the live app path. Use RazorWireHybridCredentialsMode.Auto
to include credentials automatically when a live origin is configured; use explicit include or omit only when the live endpoint contract requires it. Turbo is emitted first according to RazorWireOptions.Turbo
. Bundled and custom modes preserve the current request path base and static-asset versioning. Host-managed mode emits no Turbo tag and requires the host to finish loading a compatible Turbo runtime before this output executes. A versioned same-origin razorwire-dialog.css
link supplies the package-owned dialog shell styles, including for a server response that opens the first dialog after initial page load. Dialogs do not require inline style elements. See Docs/dialog-responses.md
for CSS variables and the opt-in server API.
ViewContext ViewContext { get; set; }
Source
Gets or sets the view context.
bool SectionCopy { get; set; }
Source
Gets or sets a value indicating whether the section-copy runtime should be eagerly rendered after the core runtime.
Section copy is split out of the core runtime so plain RazorWire pages do not pay for clipboard behavior they do not use. Plain <rw:scripts />
emits a small usage detector that loads the runtime only when the rendered page contains data-rw-section-copy
or data-rw-section-copy-target
markup. Set this attribute to true
when a host wants to eagerly fetch the section-copy asset before the detector runs.
bool FormInteractions { get; set; }
Source
Gets or sets a value indicating whether the form-interactions runtime should be eagerly rendered after the core runtime.
Form interactions are split out of the core runtime so plain RazorWire pages do not pay for local form mechanics they do not use. Plain <rw:scripts />
emits a small usage detector that loads the runtime only when the rendered page contains data-rw-form-toggle
or data-rw-form-collection
markup. Set this attribute to true
when a host wants to eagerly fetch the form-interactions asset before the detector runs.
bool BehaviorKit { get; set; }
Source
Gets or sets a value indicating whether the Behavior Kit runtime should be eagerly rendered after the core runtime.
Behavior Kit is explicit in v1 because app-owned behavior registrations need a predictable public API surface. Plain <rw:scripts />
does not lazy-load it from markup. Set this attribute to true
when a host wants window.RazorWire.behaviors
to connect root-scoped behaviors or page-lifecycle registrations.
A TagHelper that marks an element as requiring a specific Turbo Stream to be established before becoming active.
void Process(TagHelperContext context, TagHelperOutput output)
Applies stream-requirement attributes and disables the element when a requires-stream value is present.
RequiresStream
is null or whitespace, the output is left unchanged. Otherwise adds the following attributes to the element: data-rw-requires-stream
set to the RequiresStream
valuearia-disabled
to "true"
disabled
to "disabled"
(only for supported form elements)string? RequiresStream { get; set; }
Source
Gets or sets the name or identifier of the stream required by this element.
A TagHelper that renders a Turbo Frame as a "RazorWire Island", enabling partial page updates and client-side module mounting.
void Process(TagHelperContext context, TagHelperOutput output)
Renders a <turbo-frame>
element whose attributes are populated from the tag helper's properties.
ArgumentException
Id
is null, empty, or consists only of white-space characters.
Validates that Id
is not null, empty, or whitespace and sets attributes such as id, src, loading, data-turbo-permanent, data-rw-swr, style (view-transition-name), data-rw-export, and client-related data attributes when the corresponding properties are provided. The rendered frame always includes data-rw-island="true"
. The exporter treats that marker as the ownership signal for RazorWire-managed island frame URLs in hybrid output, so callers should not remove or override it when the frame should keep RazorWire island behavior.
string Id { get; set; }
Source
The unique identifier for the island, which becomes the id of the rendered turbo-frame.
string? Src { get; set; }
Source
The source URL for the turbo-frame content.
string? Loading { get; set; }
Source
The loading strategy for the turbo-frame (e.g., "eager", "lazy").
bool Permanent { get; set; }
Source
If true, the rendered element will have the 'data-turbo-permanent' attribute.
bool Swr { get; set; }
Source
If true, enables Stale-While-Revalidate behavior via 'data-rw-swr'.
string? TransitionName { get; set; }
Source
The name for the CSS View Transition, applied as 'view-transition-name' in the style attribute.
string? Export { get; set; }
Source
The name of the client-side module to export/expose.
string? ClientModule { get; set; }
Source
The client-side module specifier to mount on this island. Use a relative path, root-relative path, same-origin URL, explicit HTTPS URL, or bare import-map specifier; inline module content such as data URLs is rejected by the browser runtime.
string? ClientStrategy { get; set; }
Source
The mounting strategy for the client module (e.g., "load", "visible", "idle").
string? ClientProps { get; set; }
Source
Initial properties (JSON) to pass to the client module's mount function.
Marks an application-authored form control as a RazorWire conditional form toggle.
Use this helper when Razor markup should normalize to the canonical data-rw-form-toggle
attribute. RazorWire interprets null, blank, true
, and the sentinel rw-form-toggle
value as the default logical name true
. When applied to a button
, the helper sets type="button"
when the app has not supplied a type so toggles do not submit forms by default. The helper does not move focus, validate business rules, or generate target markup; the app owns the control and target.
string? TargetName { get; set; }
Source
Gets or sets the logical target name this control toggles.
Values are trimmed. Blank, true
, and rw-form-toggle
normalize to true
so attribute-only Razor usage has a stable default name.
bool Invert { get; set; }
Source
Gets or sets a value indicating whether the control's active state should be inverted.
The default is false
. Set this for controls such as "no action expected" checkboxes where the checked state should hide the target instead of showing it.
Marks an application-authored element as the target controlled by a RazorWire conditional form toggle.
The helper emits only data-rw-form-toggle-target
metadata. Target contents, model fields, validation messages, and layout remain app-owned. Null, blank, true
, and rw-form-toggle-target
normalize to the default logical name true
.
string? TargetName { get; set; }
Source
Gets or sets the logical toggle name that controls this target.
Values are trimmed and normalized to true
for attribute-only usage. The value must match the toggle name inside the same form.
bool DisableWhenHidden { get; set; }
Source
Gets or sets a value indicating whether descendant controls should be disabled while the target is hidden.
The default is false
. When enabled, RazorWire disables only controls it owns during the hidden state and restores only those controls when the target is shown again.
Marks an application-authored element as a model-bound collection root.
The collection root scopes row commands, templates, sparse index markers, and diagnostics for one ASP.NET Core collection property. Nested collection roots use their own index-token placeholder while remaining scoped to their owning row. This helper does not generate model fields or make app persistence decisions.
string? Name { get; set; }
Source
Gets or sets the ASP.NET Core model property name for the collection, such as Actions
.
The value is trimmed and emitted as data-rw-form-collection
. It must match the prefix used by app-authored field names and hidden .index
markers.
string? Label { get; set; }
Source
Gets or sets optional reader-facing copy for generated announcements.
The value is used only for local status messages such as add, duplicate, and remove announcements. It does not change model binding names.
string? RemoveMode { get; set; }
Source
Gets or sets the default remove mode for row commands inside this collection.
Values are passed through after trimming. The runtime recognizes mark
and mark-remove
as mark-for-removal; other values fall back to physical remove behavior.
string? IndexToken { get; set; }
Source
Gets or sets the unresolved placeholder used by this collection's row template.
The value is trimmed and emitted as data-rw-form-collection-index-token
. Missing or whitespace-only values use __index__
. A nonblank value should match __[A-Za-z][A-Za-z0-9_]*__
; nonblank values outside that syntax are emitted unchanged after trimming so the browser runtime can report a collection-scoped diagnostic. This placeholder is distinct from the concrete opaque key submitted by an enabled hidden .index
marker and from any persisted model Id
value.
Marks an application-authored element as a row inside a RazorWire form collection.
Nested rows require owned enabled hidden Collection.index
markers for ASP.NET Core sparse collection binding. Legacy one-level rows may use the existing metadata-only fallback. The helper marks the row and may emit the optional current index, but it does not create hidden markers or generated input fields.
string? Index { get; set; }
Source
Gets or sets the row's current model-binding index.
When provided, the trimmed value is emitted as data-rw-form-index
. Keep it aligned with the row's enabled hidden .index
marker.
Marks a template containing app-authored collection row markup.
Use the owning collection's FormCollectionTagHelper.IndexToken
, which defaults to __index__
, in its row binding names and enabled hidden .index
marker value. The runtime validates those owned fields and markers; a token appearing only in text or unrelated attributes is not sufficient. Nested templates require the marker; legacy top-level templates may omit it when they contain a correctly prefixed owned field, and Add creates it during final preparation. Nested unresolved ancestors use distinct local placeholders. Author IDs and their references consistently with the template fields; RazorWire rebases binding paths and maps DOM IDs separately while preserving descendant template placeholders. It does not invent application fields.
Marks a button that adds a row from the nearest collection template.
The helper emits data-rw-form-collection-add
and sets type="button"
when the app has not supplied a type. The nearest collection root and template determine what row is inserted.
Marks a button that duplicates the nearest collection row.
The helper emits data-rw-form-collection-duplicate
and sets type="button"
when absent. Duplicate requires the source row to have a resolvable sparse index so names, ids, labels, and validation references can be rewritten safely.
Marks a button that removes or marks the nearest collection row.
Use physical remove for draft-only rows whose absence from the payload is enough. Use mark-for-removal for persisted rows when the app provides hidden id/delete fields and server-side delete semantics. The helper never creates those app-owned persistence fields.
string? Mode { get; set; }
Source
Gets or sets the remove mode for this command: physical
or mark
.
Null, blank, true
, and rw-form-collection-remove
normalize to physical
. The runtime also accepts mark-remove
as a mark-for-removal command value.
A TagHelper that automatically applies version hashing to script and link tags that reference local files, if the asp-append-version attribute is missing.
bool IsLocal(string? path)
Determines if the provided path is a local path suitable for versioning.
path
true
if the path is local (starts with '/' or '~') and is not protocol-relative; otherwise, false
.
Relative paths (e.g. "css/site.css") are excluded because they are ambiguous without knowing the current request path context, which complicates server-side resolution. Use root-relative ('/') or app-relative ('~') paths for automatic versioning.
ViewContext ViewContext { get; set; }
Source
Gets or sets the view context.
This property is automatically set by the framework when the TagHelper is created.
Tag helper that renders a <time>
element with a UTC timestamp for client-side time formatting.
When rw-type="local"
, the JavaScript runtime formats the timestamp to the user's local timezone. When rw-type="utc"
, the timestamp is formatted in UTC.
<time rw-type="local" datetime="@Model.Timestamp"></time>
<time rw-type="local" datetime="@Model.Timestamp" rw-display="relative"></time>
<time rw-type="local" datetime="@Model.Timestamp" rw-display="datetime" rw-format="short"></time>
<time rw-type="utc" datetime="@Model.Timestamp"></time>
void Process(TagHelperContext context, TagHelperOutput output)
Renders a <time>
element with the UTC timestamp in the datetime
attribute and data attributes for client-side JavaScript formatting.
context
output
ArgumentException
Value
is the default value or if Display
or Format
have invalid values.string? RwType { get; set; }
Source
Gets or sets the timezone type for RazorWire time formatting. Valid values: local
(user's browser timezone) or utc
(UTC timezone).
DateTimeOffset Value { get; set; }
Source
The UTC timestamp to display, sourced from the datetime
attribute.
string Display { get; set; }
Source
Gets or sets the display mode for the formatted time. Valid values: time
(default), date
, datetime
, or relative
.
string? Format { get; set; }
Source
Gets or sets the format style for absolute time formatting. Valid values: short
, medium
(default), long
, or full
.
Projects a passive AppSurface auth result into one server-rendered RazorWire auth state.
The helper evaluates a host-owned policy through IRazorWireAuthResultProvider
and renders only the matching child slot. It never challenges, forbids, redirects, signs callers in or out, mutates cookies, chooses authentication schemes, or grants access. Protected endpoints and actions must still enforce host-owned auth.
string? Policy { get; set; }
Source
Gets or sets the host-owned policy name to project.
object? Resource { get; set; }
Source
Gets or sets an optional host-owned authorization resource.
bool IncludeDiagnostics { get; set; }
Source
Gets or sets a value indicating whether safe policy and reason diagnostics should be emitted.
Diagnostics are off by default so rendered HTML does not expose policy names, failure reasons, or setup details unless the host explicitly asks for them.
ViewContext ViewContext { get; set; }
Source
Gets or sets the current MVC view context.
Carries per-render slot resolution state for an rw:auth-view
.
Slot helpers mutate MatchedExplicitSlot
during child-content execution. Static export reads that flag after slot resolution to decide whether a protected view supplied an explicit anonymous fallback before any artifact is written.
RazorWireAuthProjectionState State { get; }
Source
Gets the projected RazorWire auth state that slot helpers compare against.
bool MatchedExplicitSlot { get; set; }
Source
Gets or sets a value indicating whether an explicit slot matching State
rendered.
Only the slot resolution path should set this flag. It must be set before rw:auth-view
evaluates the static-export missing-fallback check.
Renders child content when the surrounding auth view is allowed.
Renders child content when the surrounding auth view requires authentication.
Renders child content when the surrounding auth view is forbidden.
Renders child content when host auth setup is missing or failed.
Renders child content when the surrounding auth view has a stale or unknown session.
Renders child content when the surrounding auth view has no evaluated result.
Conditionally renders child content when the projected auth state matches.
string? Policy { get; set; }
Source
Gets or sets the host-owned policy name to project.
object? Resource { get; set; }
Source
Gets or sets an optional host-owned authorization resource.
string? State { get; set; }
Source
Gets or sets the state that should render the child content. Defaults to allowed
.
bool IncludeDiagnostics { get; set; }
Source
Gets or sets a value indicating whether safe policy and reason diagnostics should be emitted.
ViewContext ViewContext { get; set; }
Source
Gets or sets the current MVC view context.
string HelperName { get; }
Source
Gets the helper name emitted in data-rw-auth-helper
.
RazorWireAuthProjectionState TargetState { get; }
Source
Gets the projected state required for rendering.
Alias over AuthGateTagHelper
for policy-oriented allowed-state rendering.
string? State { get; set; }
Source
Hides the general gate state selector because permission gates are allowed-only aliases.
Renders a host-owned login link without initiating authentication.
The helper emits a normal anchor. The host owns the target URL and authentication behavior.
string? Href { get; set; }
Source
Gets or sets the host-owned login URL.
string? ReturnUrlPolicy { get; set; }
Source
Gets or sets the return-url policy. Use current-path
to append the current local path as returnUrl
.
ViewContext ViewContext { get; set; }
Source
Gets or sets the current MVC view context.
Renders a host-owned logout form without signing callers out.
string? Action { get; set; }
Source
Gets or sets the host-owned logout form action.
string? ReturnUrlPolicy { get; set; }
Source
Gets or sets the return-url policy. Use current-path
to include the current local path as a hidden returnUrl
input.
ViewContext ViewContext { get; set; }
Source
Gets or sets the current MVC view context.
Base class for auth-view slot helpers.
RazorWireAuthProjectionState State { get; }
Source
Gets the state that renders this slot.
A Tag Helper that enhances a standard <form>
element with RazorWire/Turbo features and loading ownership.
void Process(TagHelperContext context, TagHelperOutput output)
Processes an active form by applying its Turbo, loading, anti-forgery, and failed-form conventions.
context
output
bool Enabled { get; set; }
Source
Gets or sets a value indicating whether RazorWire/Turbo enhancement is enabled for this form. Defaults to true
.
When enabled and RazorWireOptions.Forms
. RazorWireFormOptions.Loading
is enabled, the helper emits data-rw-loading="true"
unless the form opts out with data-rw-loading="off"
. Setting this property to false
disables Turbo enhancement and removes the loading ownership marker.
string? TargetFrame { get; set; }
Source
Gets or sets the identifier of the Turbo Frame that this form should target.
string? Antiforgery { get; set; }
Source
Gets or sets the anti-forgery behavior assertion for this form.
Supported values are lazy
and off
. lazy
emits data-rw-antiforgery="lazy"
, asserting that the runtime should fetch a fresh anti-forgery token before the form is submitted. off
emits data-rw-antiforgery="off"
, an explicit opt-out that the exporter treats as unsafe if a static token is still present. When this property is unset, normal server-rendered forms keep their default ASP.NET Core anti-forgery behavior, and hybrid export can still convert RazorWire-owned static token forms to lazy refresh.
Tag helper that renders an rw-stream-source
element to establish a connection to a RazorWire stream.
void Process(TagHelperContext context, TagHelperOutput output)
Configures the rw-stream-source
element by setting its src
attribute and handling the permanent
option.
context
output
InvalidOperationException
Channel
is null, empty, or contains only whitespace.string Channel { get; set; }
Source
Gets or sets the channel name of the stream to connect to. This attribute is required.
bool Permanent { get; set; }
Source
Gets or sets a value indicating whether the stream source should be preserved across Turbo page loads.
bool Replay { get; set; }
Source
Gets or sets a value indicating whether retained channel messages should be delivered before live messages.
The default is false
. When Replay
is true
, StreamSourceTagHelper
appends ?replay=1
to the generated stream URL so MapRazorWire
can request retained messages before live delivery. Use replay for clients that need recent context before subscribing to new events. Replay can increase initial latency and bandwidth, may duplicate messages a client already processed before reconnecting, and depends on the hub implementation's retention policy.