For an employee self-service portal built as a .NET 10 Blazor Web App, mostly static pages plus a few interactive widgets, how would you choose render modes?
answer
- static first, interactive where needed
- per-page versus global interactivity
- circuit memory versus download size
- [ExcludeFromInteractiveRouting] for cookie pages
- standalone WebAssembly when no server rendering
basics
~20 sDefault to static SSR for read-mostly pages and put an interactive mode only on the widgets that need it, choosing Server, WebAssembly or Auto from latency, concurrent users, offline needs and data access. Revisit if most pages become interactive or the portal must work offline.
solid answer
~50 sI would start **static-first with per-page interactivity**: payslips, policies and the directory are static SSR (with `[StreamRendering]` for slow sections), and only widgets such as the leave-request form or a shift calendar get a mode. For those I pick **Interactive Server** when users are on the corporate network, concurrent sessions are in the hundreds or low thousands and the widget needs server data directly - no API to build, nothing secret shipped. I pick **WebAssembly** when interaction is heavy or latency-sensitive, users are on poor mobile connections, or circuits would cost too much memory - accepting an authenticated API and a bigger first load. **Auto** is for when both fast first interaction and long-term offload matter and the team can test every component in both runtimes. If most pages become interactive I switch to global interactivity on `Routes` with `[ExcludeFromInteractiveRouting]` for cookie-writing pages; a real offline requirement points to a standalone WebAssembly app.
go deeper
Know that pages can differ: some static, some interactive, and that the mode can be set on a single component instead of the whole page.
Explain per-page versus global interactivity and the main reasons to pick Server, WebAssembly or Auto for one widget.
Back each widget's mode with numbers - circuits and memory, event latency, first-load size - and handle the cookie pages and data-access split that global interactivity and Auto bring.
Own the portfolio rule: static-first, a short list of approved interactive patterns, the metrics that trigger a change of mode, and when a standalone WebAssembly app is the better product.
## Framing the decision A **Blazor Web App** lets every page - even every component - pick a **render mode**: static server-side rendering (**static SSR**), **Interactive Server**, **Interactive WebAssembly** or **Interactive Auto**. For an employee self-service portal most screens are read-mostly (payslips, leave balances, policies, the staff directory), and a few are genuinely interactive (a multi-step leave request, a shift-swap calendar, an expense form with live totals). There is no single right answer; a lead is expected to state the forces and the evidence that would change the choice. ## Step 1: static unless proven otherwise Static SSR is the cheapest mode: no circuit, no WebAssembly download, no per-user state kept between requests, and request-scoped services. A static page can still post forms (an `EditForm` with a `FormName`), navigate smoothly with enhanced navigation and show slow sections progressively with `[StreamRendering]`. So the default for read-mostly pages is **no render mode**, and interactivity is added per page or per component instance. ## Step 2: pick the mode for each interactive widget | Force | Points to Interactive Server | Points to Interactive WebAssembly | |---|---|---| | Network | users on a LAN or VPN with low latency | mobile or remote users with high or variable latency | | Concurrent users | hundreds to low thousands; memory per circuit is affordable | many thousands; per-user server state is too costly | | Interaction style | form-like, a few events per minute | drag and drop, typing-heavy, many events per second | | Data access | direct use of server services, no API needed | an authenticated HTTP API exists or is worth building | | Secrets and rules | logic must stay on the server | logic may be public (it ships to the browser) | | First interaction | fast, after the circuit connects | slower on a first visit while the runtime downloads | **Interactive Auto** combines both: a widget starts on Server while the WebAssembly files download, and later visits use WebAssembly. It costs the most engineering: components live in the `.Client` project, must run correctly in both places, and usually need a data-access abstraction with a server implementation and an HTTP implementation. I would choose it for a busy, high-traffic widget where both first-visit speed and long-term server offload matter - not by default. Avoid mixing Server and WebAssembly widgets on one page without a reason: the page then runs two runtimes that share no state. ## Step 3: per-page or global interactivity - **Per page** (the template default): the layout is static, each interactive page or widget declares a mode. Best when interactive pages are the minority. - **Global**: `<Routes @rendermode="..." />` and `<HeadOutlet>` in `App.razor` make every page interactive, with client-side routing between pages and interactive layouts. Pages that must run in a real HTTP request - sign-in and anything that writes cookies - are marked `@attribute [ExcludeFromInteractiveRouting]`, and `App.razor` uses `HttpContext.AcceptsInteractiveRouting()` to give them a `null` (static) mode, forcing a full page load. This is the shape the template generates for global interactivity with individual accounts. I switch to global when most pages are interactive or the navigation shell itself needs interactivity. ## Step 4: when a Blazor Web App is the wrong host A **standalone Blazor WebAssembly app** (the `blazorwasm` template, `Microsoft.NET.Sdk.BlazorWebAssembly`) has no render modes at all: it publishes static files that any static host or CDN can serve and runs entirely in the browser, optionally as an installable progressive web app with a service worker. It fits a portal that must keep working offline or cannot host ASP.NET Core, at the cost of no server prerendering and a separate API. ## What would change my mind 1. **Measured circuit cost** - concurrent circuits and memory per circuit under real load - pushing widgets from Server to WebAssembly. 2. **Event latency at the 95th percentile** for remote staff, with the same effect. 3. **Time to interactive** on a first visit, pushing a WebAssembly widget to Auto or back to Server. 4. **A requirement to work offline**, pushing towards standalone WebAssembly. 5. **Most pages turning interactive**, pushing towards global interactivity.
- Why would the sign-in page stay static SSR even under global interactivity?Signing in writes an authentication cookie, which needs a real HTTP request and response. An interactive page runs over a circuit or in the browser after the response has finished, so it cannot set response cookies. Marking the page `[ExcludeFromInteractiveRouting]` makes navigation to it a full page load, and `App.razor` gives it a `null` render mode via `HttpContext.AcceptsInteractiveRouting()`.
- What does choosing Auto add to the testing and security plan?Every Auto component must be tested on both runtimes, because a first visit runs it on the server and later visits in the browser. Its data access must go through an abstraction with a server implementation and an HTTP implementation, and the HTTP API behind it needs its own authorization, since the browser can call it directly. Anything the component contains is public once it ships to WebAssembly.
- Make the whole portal InteractiveServer so every page behaves the same way.
- Interactive WebAssembly is always faster, so every widget should use it.
- Interactive Auto gives the benefits of both modes with no extra engineering cost.
- A Blazor Web App with Interactive WebAssembly keeps working offline like a standalone PWA.
- Server and WebAssembly widgets on one page share scoped services and state.
Assumes .NET 10 Blazor Web Apps; [ExcludeFromInteractiveRouting] and RendererInfo arrived in .NET 9, and render modes themselves in .NET 8.