Layout & BodyBuilder

Control the body shell without breaking the page pipeline.

What BodyBuilder is responsible for

PageBuilder separates the document lifecycle from the body shell. The document lifecycle is handled by PageBuilder , while the structure of the body itself is delegated to an IBodyBuilder . This makes it possible to customize how the header, main content area, and footer are structured, while preserving a single and consistent rendering pipeline for the page as a whole.

A body builder is responsible for framing the body-level structure of the page. Depending on its implementation, it can control:

The opening body tag
The header section
The main section
The footer section
The closing body structure

How it fits into the pipeline

The PageBuilder pipeline captures the body, lets components enrich PageInformation , then emits the final document. Within that final document rendering process, the active IBodyBuilder defines the body shell used around the captured content.

Key distinction

PageBuilder controls the document lifecycle. IBodyBuilder controls the body framing inside that lifecycle. BodyBuilder does not replace the pipeline — it participates in it.

Why this separation matters

In many ASP.NET applications, body structure ends up spread across layouts, partials, helpers, and view-specific conventions. Over time, this makes the page shell harder to understand and harder to standardize.

By introducing IBodyBuilder , PageBuilder gives you a dedicated place to define body-level structure without mixing it into unrelated rendering code. This allows PageBuilder to remain generic while still supporting application-level layout conventions.

Typical usage

A body builder is generally configured at the page level and then used by PageBuilder during the final document rendering process. This means pages and components do not need to know all structural details of the outer body shell. They render their content and contribute dependencies to the shared page model. The body shell is then assembled centrally.

Recommended usage

Use IBodyBuilder to define application-level body conventions
Keep the document lifecycle inside PageBuilder
Do not scatter header, main, and footer logic across many views when a body builder can centralize it
Keep the shared page model compatible with body-first rendering

Continue with HtmlBuilderBase

Understand the technical foundation shared by all builders.

HtmlBuilderBase →