I would assume this is referring to client or server, but with these as the options I can't quite figure this.
Lots of choice, but when you don't understand what they mean??????
The difference is where the render mode is set for the SPA.
When you select Global, the render mode is set in App.razor
on the two components. This overrides any "lower" settings in child components.
The example below sets it to InterActiveServer
.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="app.css" />
<link rel="stylesheet" href="SSR.Server.styles.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet @rendermode="InteractiveServer" />
</head>
<body>
<Routes @rendermode="InteractiveServer" />
<script src="_framework/blazor.web.js"></script>
</body>
</html>
When you select Page/Component
, App
looks likes this. No render modes defines so Server Side Rendered is default unless set specifically at the page or component level.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="app.css" />
<link rel="stylesheet" href="SSR.Server.styles.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet />
</head>
<body>
<Routes />
<script src="_framework/blazor.web.js"></script>
</body>
</html>
Add this simple component to your solution and add it to any page. It will tell you what render state is being used for that page. It will also change state as the component switches from pre-rendered to fully interactive.
RenderContextState.razor
<div class="@_alertCss m-2">
@_alertText
</div>
@code {
private bool _rendered;
private string _alertCss => _rendered ? "alert alert-success" : "alert alert-danger";
private string _alertText => _rendered ? "Interactively Rendered" : "Statically Rendered";
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
_rendered = true;
// We Shouldn't really do this but we need to display the result of the component mutation
// OnAfterRender should only normally be used for JSInterop code
this.StateHasChanged();
}
}
}
For instance:
@page "/"
<PageTitle>Home</PageTitle>
<RenderContextState />
<h1>Hello, world!</h1>
Welcome to your new app.
All the WebAssembly modes on the Blazor Web App
template are AspNetCore Hosted. The template deploys a Server and Client project.
If you want standalone WASM use the Blazor WebAssembly Standalone App
template.
I'm in the middle of writing an article on this very [confusing] subject. I'll add a reference to this answer when it's complete.
This refers to the new features added to Blazor in .NET 8
You can have your app be globally interactive (Blazor Server or WASM or both) or mixed (some components are static SSR and some interactive)
To keep it as simple as possible:
Global Interactivity in Blazor means any interaction or state-change can potentially affect the whole app. Making a change in one page/component may cause the entire application to be refreshed or re-rendered
(The state of all components/pages are refreshed together).
In contrast, Per-Page or Per-Component Interactivity isolates the interactive (refresh)behaviour to specific parts of your application. This approach is a bit more efficient as it limits the scope of real-time updates to only the components/pages that need it.
State changes within individual components/pages are displayed without having to update/refresh every single page/component.
© 2022 - 2025 — McMap. All rights reserved.
Per page/component
mode. How it works, the pitfalls, why it does certain things. Note that the conclusions are a personal view. github.com/ShaunCurtis/Blazor.ExploreRendering/blob/master/… – Tila