liveBook · Manning

Render-mode attribute

As explained in Pro ASP.NET Core 7, Tenth Edition

A render-mode attribute is a Razor attribute that selects how a component's content is produced and delivered.

The render-mode attribute selects how a Razor Component produces and delivers content when embedded in a controller view or Razor Page. section 33.3.2

Choose among three rendering behaviors:

  • Static renders the component as HTML without client-side support. section 33.3.2
  • Server sends a placeholder first, then delivers the component’s HTML over a persistent HTTP connection. section 33.3.2
  • ServerPrerendered sends initial static HTML immediately, then replaces it with dynamic content after the connection is established. section 33.3.2

Embedding PeopleList

A controller view selects server rendering with <component type="typeof(Advanced.Blazor.PeopleList)" render-mode="Server" />. Requesting /controllers lets the component respond to the select element without a form submission. section 33.3.2

Table 33.3 The RenderMode values (view table figure)

Name

Description

Static

The Razor Component renders its view section as static HTML with no client-side support.

Server

The HTML document is sent to the browser with a placeholder for the component. The HTML displayed by the component is sent to the browser over the persistent HTTP connection and displayed to the user.

ServerPrerendered

The view section of the component is included in the HTML and displayed to the user immediately. The HTML content is sent again over the persistent HTTP connection.

Compare the Static, Server, and ServerPrerendered behaviors and their HTML delivery sequences. section 33.3.2

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Defines three modes and explains placeholders, prerendered HTML, and dynamic replacement, but does not detail connection setup.
Examples
Uses the PeopleList component, a controller view, the /controllers route, and Static, Server, and ServerPrerendered alternatives.
What it assumes
Assumes Razor Components and component elements, while defining render-mode choices and their delivery effects.
What you can do after
Operate/configure a Razor Component by choosing a render mode and observing its browser delivery behavior.
How it connects
Connects Razor Components with controller views, Razor Pages, the RenderMode enum, HTML delivery, and persistent HTTP connections.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.