Getting Started — PageBuilder

Install the rendering foundation and wire the body-first page pipeline.

1. Install the NuGet Package

Start here when you want the PageBuilder document lifecycle before adopting BootstrapBuilder, EffectBuilder, ComponentBuilder or DocumentationViewer.

Install DMBPageBuilder
dotnet add package DMBPageBuilder

2. Configure Services

Load the common configuration before building the application service provider. This registers the page registry and document pipeline.

Program.cs
using DMBPageBuilder;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

PageBuilderConfiguration.LoadCommonConfig(builder);

builder.Services.AddControllersWithViews();

3. Add Razor Imports

Add PageBuilder to _ViewImports.cshtml so views and layouts can create builders and access page state.

_ViewImports.cshtml
@using DMBPageBuilder
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

4. Apply the Layout Pattern

The core pattern captures the body first so components can register page-level assets before the document head is emitted.

_Layout.cshtml
@{
    var originalWriter = ViewContext.Writer;
    var bodyWriter = new StringWriter();

    try
    {
        ViewContext.Writer = bodyWriter;
        RenderBody().WriteTo(ViewContext.Writer, HtmlEncoder);
    }
    finally
    {
        ViewContext.Writer = originalWriter;
    }

    var bodyHtml = bodyWriter.ToString();
    PageInformation page = PageRegistry.GetPageInformation(Context) ?? new PageInformation();
    PageBuilder builder = Html.PageBuilder(page);
}

@builder.RenderDocumentStart(Context)
@Html.Raw(bodyHtml)
@builder.RenderDocumentEnd(Context)
Key API
PageBuilderConfiguration.LoadCommonConfig(...)
PageRegistry.GetOrCreatePageInformation(...)
Html.PageBuilder(page)
builder.RenderDocumentStart(...)
builder.RenderDocumentEnd(...)

Understand how PageBuilder separates document orchestration from component rendering.

Check out the architecture guide to understand how PageBuilder manages resources and rendering.

Architecture