AppSurface Search
API Reference

TagHelpers

Type

RequiresStreamTagHelper

Source

A TagHelper that marks an element as requiring a specific Turbo Stream to be established before becoming active.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Applies stream-requirement attributes and disables the element when a requires-stream value is present.

Remarks

If 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 value
  • aria-disabled to "true"
  • disabled to "disabled" (only for supported form elements)
The element is therefore disabled until client-side code removes or updates these attributes.
Property

RequiresStream

string? RequiresStream { get; set; } Source

Gets or sets the name or identifier of the stream required by this element.

Type

LocalTimeTagHelper

Source

Tag helper that renders a <time> element with a UTC timestamp for client-side time formatting.

Remarks

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.

Example

<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>
Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Renders a <time> element with the UTC timestamp in the datetime attribute and data attributes for client-side JavaScript formatting.

Parameters

  • contextContains information associated with the current HTML tag.
  • outputA stateful HTML element used to generate an HTML tag.

Exceptions

  • ArgumentExceptionThrown when Value is the default value or if Display or Format have invalid values.
Property

RwType

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

Property

Value

DateTimeOffset Value { get; set; } Source

The UTC timestamp to display, sourced from the datetime attribute.

Property

Display

string Display { get; set; } Source

Gets or sets the display mode for the formatted time. Valid values: time (default), date, datetime, or relative.

Property

Format

string? Format { get; set; } Source

Gets or sets the format style for absolute time formatting. Valid values: short, medium (default), long, or full.

Type

RazorWireFormTagHelper

Source

A Tag Helper that enhances a standard <form> element with RazorWire/Turbo features.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Processes a form tag by removing attributes that start with "rw-" and configuring Turbo attributes based on the tag helper's properties.

Parameters

  • contextThe context for the current tag helper execution.
  • outputThe tag helper output whose attributes will be modified.
Property

Enabled

bool Enabled { get; set; } Source

Gets or sets a value indicating whether RazorWire/Turbo enhancement is enabled for this form. Defaults to true.

Property

TargetFrame

string? TargetFrame { get; set; } Source

Gets or sets the identifier of the Turbo Frame that this form should target.

Property

Antiforgery

string? Antiforgery { get; set; } Source

Gets or sets the anti-forgery behavior assertion for this form.

Remarks

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.

Type

AutoAssetVersioningTagHelper

Source

A TagHelper that automatically applies version hashing to script and link tags that reference local files, if the asp-append-version attribute is missing.

Method

IsLocal

bool IsLocal(string? path) Source

Determines if the provided path is a local path suitable for versioning.

Parameters

  • pathThe path to check.

Returns

true if the path is local (starts with '/' or '~') and is not protocol-relative; otherwise, false.

Remarks

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.

Property

ViewContext

ViewContext ViewContext { get; set; } Source

Gets or sets the view context.

Remarks

This property is automatically set by the framework when the TagHelper is created.

Type

IslandTagHelper

Source

A TagHelper that renders a Turbo Frame as a "RazorWire Island", enabling partial page updates and client-side module mounting.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Renders a <turbo-frame> element whose attributes are populated from the tag helper's properties.

Exceptions

  • ArgumentExceptionThrown when Id is null, empty, or consists only of white-space characters.

Remarks

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.

Property

Id

string Id { get; set; } Source

The unique identifier for the island, which becomes the id of the rendered turbo-frame.

Property

Src

string? Src { get; set; } Source

The source URL for the turbo-frame content.

Property

Loading

string? Loading { get; set; } Source

The loading strategy for the turbo-frame (e.g., "eager", "lazy").

Property

Permanent

bool Permanent { get; set; } Source

If true, the rendered element will have the 'data-turbo-permanent' attribute.

Property

Swr

bool Swr { get; set; } Source

If true, enables Stale-While-Revalidate behavior via 'data-rw-swr'.

Property

TransitionName

string? TransitionName { get; set; } Source

The name for the CSS View Transition, applied as 'view-transition-name' in the style attribute.

Property

Export

string? Export { get; set; } Source

The name of the client-side module to export/expose.

Property

ClientModule

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.

Property

ClientStrategy

string? ClientStrategy { get; set; } Source

The mounting strategy for the client module (e.g., "load", "visible", "idle").

Property

ClientProps

string? ClientProps { get; set; } Source

Initial properties (JSON) to pass to the client module's mount function.

Type

AuthViewTagHelper

Source

Projects a passive AppSurface auth result into one server-rendered RazorWire auth state.

Remarks

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.

Property

Policy

string? Policy { get; set; } Source

Gets or sets the host-owned policy name to project.

Property

Resource

object? Resource { get; set; } Source

Gets or sets an optional host-owned authorization resource.

Property

IncludeDiagnostics

bool IncludeDiagnostics { get; set; } Source

Gets or sets a value indicating whether safe policy and reason diagnostics should be emitted.

Remarks

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.

Property

ViewContext

ViewContext ViewContext { get; set; } Source

Gets or sets the current MVC view context.

Type

AuthSlotContext

Source

Carries per-render slot resolution state for an rw:auth-view.

Remarks

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.

Property

State

RazorWireAuthProjectionState State { get; } Source

Gets the projected RazorWire auth state that slot helpers compare against.

Property

MatchedExplicitSlot

bool MatchedExplicitSlot { get; set; } Source

Gets or sets a value indicating whether an explicit slot matching State rendered.

Remarks

Only the slot resolution path should set this flag. It must be set before rw:auth-view evaluates the static-export missing-fallback check.

Type

AuthAllowedSlotTagHelper

Source

Renders child content when the surrounding auth view is allowed.

Type

AuthAnonymousSlotTagHelper

Source

Renders child content when the surrounding auth view requires authentication.

Type

AuthForbiddenSlotTagHelper

Source

Renders child content when the surrounding auth view is forbidden.

Type

AuthSetupFailureSlotTagHelper

Source

Renders child content when host auth setup is missing or failed.

Type

AuthUnsafeNavigationSlotTagHelper

Source

Renders child content when a return or navigation target was unsafe.

Type

AuthStaleSlotTagHelper

Source

Renders child content when the surrounding auth view has a stale or unknown session.

Type

AuthUnknownSlotTagHelper

Source

Renders child content when the surrounding auth view has no evaluated result.

Type

AuthGateTagHelper

Source

Conditionally renders child content when the projected auth state matches.

Property

Policy

string? Policy { get; set; } Source

Gets or sets the host-owned policy name to project.

Property

Resource

object? Resource { get; set; } Source

Gets or sets an optional host-owned authorization resource.

Property

State

string? State { get; set; } Source

Gets or sets the state that should render the child content. Defaults to allowed.

Property

IncludeDiagnostics

bool IncludeDiagnostics { get; set; } Source

Gets or sets a value indicating whether safe policy and reason diagnostics should be emitted.

Property

ViewContext

ViewContext ViewContext { get; set; } Source

Gets or sets the current MVC view context.

Property

HelperName

string HelperName { get; } Source

Gets the helper name emitted in data-rw-auth-helper.

Property

TargetState

RazorWireAuthProjectionState TargetState { get; } Source

Gets the projected state required for rendering.

Type

PermissionGateTagHelper

Source

Alias over AuthGateTagHelper for policy-oriented allowed-state rendering.

Property

State

string? State { get; set; } Source

Hides the general gate state selector because permission gates are allowed-only aliases.

Type

LoginLinkTagHelper

Source

Renders a host-owned login link without initiating authentication.

Remarks

The helper emits a normal anchor. The host owns the target URL and authentication behavior.

Property

Href

string? Href { get; set; } Source

Gets or sets the host-owned login URL.

Property

ReturnUrlPolicy

string? ReturnUrlPolicy { get; set; } Source

Gets or sets the return-url policy. Use current-path to append the current local path as returnUrl.

Property

ViewContext

ViewContext ViewContext { get; set; } Source

Gets or sets the current MVC view context.

Type

LogoutButtonTagHelper

Source

Renders a host-owned logout form without signing callers out.

Property

Action

string? Action { get; set; } Source

Gets or sets the host-owned logout form action.

Property

ReturnUrlPolicy

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.

Property

ViewContext

ViewContext ViewContext { get; set; } Source

Gets or sets the current MVC view context.

Type

AuthSlotTagHelper

Source

Base class for auth-view slot helpers.

Property

State

RazorWireAuthProjectionState State { get; } Source

Gets the state that renders this slot.

Type

FormToggleTagHelper

Source

Marks an application-authored form control as a RazorWire conditional form toggle.

Remarks

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.

Property

TargetName

string? TargetName { get; set; } Source

Gets or sets the logical target name this control toggles.

Remarks

Values are trimmed. Blank, true, and rw-form-toggle normalize to true so attribute-only Razor usage has a stable default name.

Property

Invert

bool Invert { get; set; } Source

Gets or sets a value indicating whether the control's active state should be inverted.

Remarks

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.

Type

FormToggleTargetTagHelper

Source

Marks an application-authored element as the target controlled by a RazorWire conditional form toggle.

Remarks

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.

Property

TargetName

string? TargetName { get; set; } Source

Gets or sets the logical toggle name that controls this target.

Remarks

Values are trimmed and normalized to true for attribute-only usage. The value must match the toggle name inside the same form.

Property

DisableWhenHidden

bool DisableWhenHidden { get; set; } Source

Gets or sets a value indicating whether descendant controls should be disabled while the target is hidden.

Remarks

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.

Type

FormCollectionTagHelper

Source

Marks an application-authored element as a one-dimensional model-bound collection root.

Remarks

The collection root scopes row commands, templates, sparse index markers, and diagnostics for one ASP.NET Core collection property. RazorWire stable v1 intentionally does not support nested collections, reordering, generated model fields, or app persistence decisions.

Property

Name

string? Name { get; set; } Source

Gets or sets the ASP.NET Core model property name for the collection, such as Actions.

Remarks

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.

Property

Label

string? Label { get; set; } Source

Gets or sets optional reader-facing copy for generated announcements.

Remarks

The value is used only for local status messages such as add, duplicate, and remove announcements. It does not change model binding names.

Property

RemoveMode

string? RemoveMode { get; set; } Source

Gets or sets the default remove mode for row commands inside this collection.

Remarks

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.

Type

FormCollectionRowTagHelper

Source

Marks an application-authored element as a row inside a RazorWire form collection.

Remarks

Rows must contain app-owned hidden Collection.index markers for ASP.NET Core sparse collection binding. The helper marks the row and may emit the optional current index, but it does not create hidden markers or generated input fields.

Property

Index

string? Index { get; set; } Source

Gets or sets the row's current model-binding index.

Remarks

When provided, the trimmed value is emitted as data-rw-form-index. Keep it aligned with the row's enabled hidden .index marker.

Type

FormCollectionTemplateTagHelper

Source

Marks a template containing app-authored collection row markup.

Remarks

The template must contain the literal __index__ token in row field names, ids, label references, validation references, and the hidden .index value. RazorWire clones and rewrites this markup but does not invent app fields.

Type

FormCollectionAddTagHelper

Source

Marks a button that adds a row from the nearest collection template.

Remarks

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.

Type

FormCollectionDuplicateTagHelper

Source

Marks a button that duplicates the nearest collection row.

Remarks

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.

Type

FormCollectionRemoveTagHelper

Source

Marks a button that removes or marks the nearest collection row.

Remarks

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.

Property

Mode

string? Mode { get; set; } Source

Gets or sets the remove mode for this command: physical or mark.

Remarks

Null, blank, true, and rw-form-collection-remove normalize to physical. The runtime also accepts mark-remove as a mark-for-removal command value.

Type

StreamSourceTagHelper

Source

Tag helper that renders an rw-stream-source element to establish a connection to a RazorWire stream.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Configures the rw-stream-source element by setting its src attribute and handling the permanent option.

Parameters

  • contextContains information associated with the current HTML tag.
  • outputA stateful HTML element used to generate an HTML tag.

Exceptions

  • InvalidOperationExceptionThrown when Channel is null, empty, or contains only whitespace.
Property

Channel

string Channel { get; set; } Source

Gets or sets the channel name of the stream to connect to. This attribute is required.

Property

Permanent

bool Permanent { get; set; } Source

Gets or sets a value indicating whether the stream source should be preserved across Turbo page loads.

Property

Replay

bool Replay { get; set; } Source

Gets or sets a value indicating whether retained channel messages should be delivered before live messages.

Remarks

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.

Type

PageNavigationRootTagHelper

Source

Marks an application-authored element as a RazorWire same-page navigation root.

Remarks

The helper preserves the host element and emits data-rw-page-nav="true". RazorWire owns only behavior and state attributes; the host application owns layout, breakpoints, colors, and spacing.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Emits the RazorWire page-navigation root marker when enabled.

Parameters

  • contextThe current tag helper context.
  • outputThe tag helper output to modify.
Property

Enabled

bool Enabled { get; set; } Source

Gets or sets a value indicating whether page navigation enhancement is enabled.

Type

PageNavigationLinkTagHelper

Source

Marks a normal same-page anchor as part of the nearest RazorWire page-navigation root.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Emits the page-navigation link marker when enabled.

Parameters

  • contextThe current tag helper context.
  • outputThe tag helper output to modify.
Property

Enabled

bool Enabled { get; set; } Source

Gets or sets a value indicating whether the link should be managed by RazorWire page navigation.

Type

PageNavigationToggleTagHelper

Source

Marks a button as the optional toggle for an application-owned page-navigation panel.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Emits the page-navigation toggle marker and optional aria-controls relationship.

Parameters

  • contextThe current tag helper context.
  • outputThe tag helper output to modify.
Property

Controls

string? Controls { get; set; } Source

Gets or sets the optional id of the panel controlled by this toggle.

Remarks

When a non-empty value other than the boolean sentinels true or false is supplied, the helper emits it as aria-controls unless the button already defines aria-controls.

Type

PageNavigationPanelTagHelper

Source

Marks an application-authored element as the optional panel controlled by page-navigation toggle state.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Emits the page-navigation panel marker when enabled.

Parameters

  • contextThe current tag helper context.
  • outputThe tag helper output to modify.
Property

Enabled

bool Enabled { get; set; } Source

Gets or sets a value indicating whether the panel should be managed by RazorWire page navigation.

Type

RazorWireScriptsTagHelper

Source

Tag helper for rendering the necessary RazorWire scripts.

Method

Process

void Process(TagHelperContext context, TagHelperOutput output) Source

Renders the client-side script tags required by RazorWire and removes the wrapper element so no enclosing tag is emitted.

Parameters

  • contextThe current tag helper context.
  • outputThe tag helper output that will be modified to contain the script elements and have no wrapper tag.

Exceptions

  • InvalidOperationExceptionThrown when RazorWireOptions.Hybrid.RazorWireHybridOptions.LiveOrigin is not an absolute HTTP(S) origin or includes a path, query string, fragment, or userinfo.

Remarks

The generated runtime script includes data attributes for form failure UX, development diagnostics, split-origin live origin, hybrid credential behavior, and the lazy anti-forgery token endpoint. 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.

Property

ViewContext

ViewContext ViewContext { get; set; } Source

Gets or sets the view context.

Property

PageNavigation

bool PageNavigation { get; set; } Source

Gets or sets a value indicating whether the page-navigation runtime should be eagerly rendered after the core runtime.

Remarks

Page navigation is split out of the core runtime to keep the default startup path lightweight. Plain <rw:scripts /> emits a small usage detector that loads the runtime only when the rendered page contains rw-page-nav / data-rw-page-nav markup. Set this attribute to true only when a host wants to eagerly fetch the page-navigation asset before the detector runs.

Property

SectionCopy

bool SectionCopy { get; set; } Source

Gets or sets a value indicating whether the section-copy runtime should be eagerly rendered after the core runtime.

Remarks

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.

Property

FormInteractions

bool FormInteractions { get; set; } Source

Gets or sets a value indicating whether the form-interactions runtime should be eagerly rendered after the core runtime.

Remarks

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.

Property

BehaviorKit

bool BehaviorKit { get; set; } Source

Gets or sets a value indicating whether the Behavior Kit runtime should be eagerly rendered after the core runtime.

Remarks

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.