You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/components/prerender.md
+37-10Lines changed: 37 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,7 @@ The following counter component persists counter state during prerendering and r
106
106
}
107
107
```
108
108
109
-
<!-- HOLD until https://github.com/dotnet/aspnetcore/issues/61456
109
+
<!--UPDATE 10.0 - HOLD until https://github.com/dotnet/aspnetcore/issues/61456
110
110
is resolved
111
111
112
112
```razor
@@ -123,11 +123,11 @@ The following counter component persists counter state during prerendering and r
123
123
124
124
@code {
125
125
[SupplyParameterFromPersistentComponentState]
126
-
public int CurrentCount { get; set; }
126
+
public int? CurrentCount { get; set; }
127
127
128
128
protected override void OnInitialized()
129
129
{
130
-
if (CurrentCount == 0)
130
+
if (CurrentCount is null)
131
131
{
132
132
CurrentCount = Random.Shared.Next(100);
133
133
Logger.LogInformation("CurrentCount set to {Count}", CurrentCount);
@@ -373,15 +373,27 @@ Disabling enhanced navigation, which reduces performance but also avoids the pro
373
373
Prerendering guidance is organized in the Blazor documentation by subject matter. The following links cover all of the prerendering guidance throughout the documentation set by subject:
374
374
375
375
* Fundamentals
376
-
*<xref:Microsoft.AspNetCore.Components.Routing.Router.OnNavigateAsync> is executed *twice* when prerendering: [Handle asynchronous navigation events with `OnNavigateAsync`](xref:blazor/fundamentals/routing#handle-asynchronous-navigation-events-with-onnavigateasync)
377
-
*[Startup: Control headers in C# code](xref:blazor/fundamentals/startup#control-headers-in-c-code)
376
+
*[Overview: Client and server rendering concepts](xref:blazor/fundamentals/index#client-and-server-rendering-concepts)
377
+
* Routing
378
+
*[Static versus interactive routing](xref:blazor/fundamentals/routing#static-versus-interactive-routing)
379
+
*[Route to components from multiple assemblies: Interactive routing](xref:blazor/fundamentals/routing#interactive-routing)
380
+
*<xref:Microsoft.AspNetCore.Components.Routing.Router.OnNavigateAsync> is executed *twice* when prerendering: [Handle asynchronous navigation events with `OnNavigateAsync`](xref:blazor/fundamentals/routing#handle-asynchronous-navigation-events-with-onnavigateasync)
381
+
* Startup
382
+
*[Control headers in C# code](xref:blazor/fundamentals/startup#control-headers-in-c-code)
*[Environments: Read the environment client-side in a Blazor Web App](xref:blazor/fundamentals/environments#read-the-environment-client-side-in-a-blazor-web-app)
*[SignalR: Prerendered state size and SignalR message size limit](xref:blazor/fundamentals/signalr#prerendered-state-size-and-signalr-message-size-limit)
*[Detect rendering location, interactivity, and assigned render mode at runtime](xref:blazor/components/render-modes#detect-rendering-location-interactivity-and-assigned-render-mode-at-runtime)
395
+
*[Client-side services fail to resolve during prerendering](xref:blazor/components/render-modes#client-side-services-fail-to-resolve-during-prerendering)
@@ -391,9 +403,24 @@ Prerendering guidance is organized in the Blazor documentation by subject matter
391
403
*[`QuickGrid` component sample app](xref:blazor/components/quickgrid#sample-app): The [**QuickGrid for Blazor** sample app](https://aspnet.github.io/quickgridsamples/) is hosted on GitHub Pages. The site loads fast thanks to static prerendering using the community-maintained [`BlazorWasmPrerendering.Build` GitHub project](https://github.com/jsakamoto/BlazorWasmPreRendering.Build).
392
404
*[Prerendering when integrating components into Razor Pages and MVC apps](xref:blazor/components/integration)
393
405
406
+
*[Call a web API: Prerendered data](xref:blazor/call-web-api#prerendered-data)
407
+
408
+
*[File uploads: Upload files to a server with client-side rendering (CSR)](xref:blazor/file-uploads#upload-files-to-a-server-with-client-side-rendering-csr)
409
+
410
+
*[Globalization and localization: Location override using "Sensors" pane in developer tools](xref:blazor/globalization-localization#location-override-using-sensors-pane-in-developer-tools)
*[Server-side unauthorized content display while prerendering with a custom `AuthenticationStateProvider`](xref:blazor/security/index#unauthorized-content-display-while-prerendering-with-a-custom-authenticationstateprovider)
397
-
*[Blazor WebAssembly rendered component authentication with prerendering](xref:blazor/security/webassembly/additional-scenarios#prerendering-with-authentication)
414
+
* Blazor server-side security overview
415
+
*[Manage authentication state in Blazor Web Apps](xref:blazor/security/index#manage-authentication-state-in-blazor-web-apps)
416
+
*[Unauthorized content display while prerendering with a custom `AuthenticationStateProvider`](xref:blazor/security/index#unauthorized-content-display-while-prerendering-with-a-custom-authenticationstateprovider)
417
+
*[Blazor server-side additional scenarios: Reading tokens from `HttpContext`](xref:blazor/security/additional-scenarios#reading-tokens-from-httpcontext)
*[State management: Handle prerendering](xref:blazor/state-management#handle-prerendering): Besides the *Handle prerendering* section, several of the article's other sections include remarks on prerendering.
425
+
426
+
For .NET 7 or earlier, see [Blazor WebAssembly security additional scenarios: Prerendering with authentication](xref:blazor/security/webassembly/additional-scenarios?view=aspnetcore-7.0&preserve-view=true#prerendering-with-authentication). After viewing the content in this section, reset the documentation article version selector dropdown to the latest .NET release version to ensure that documentation pages load for the latest release on subsequent visits.
Copy file name to clipboardExpand all lines: aspnetcore/blazor/components/render-modes.md
+46-46Lines changed: 46 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -209,6 +209,52 @@ The following example applies interactive server-side rendering (interactive SSR
209
209
210
210
Additional information on render mode propagation is provided in the [Render mode propagation](#render-mode-propagation) section later in this article. The [Static SSR pages in an interactive app](#static-ssr-pages-in-an-interactive-app) section shows how to use the preceding approach to adopt static SSR in an otherwise interactive app.
211
211
212
+
## Blazor documentation examples for Blazor Web Apps
213
+
214
+
When using a Blazor Web App, most of the Blazor documentation example components ***require*** interactivity to function and demonstrate the concepts covered by the articles. When you test an example component provided by an article, make sure that either the app adopts global interactivity or the component adopts an interactive render mode.
215
+
216
+
## Prerendering
217
+
218
+
*Prerendering* is the process of initially rendering page content on the server without enabling event handlers for rendered controls. The server outputs the HTML UI of the page as soon as possible in response to the initial request, which makes the app feel more responsive to users. Prerendering can also improve [Search Engine Optimization (SEO)](https://developer.mozilla.org/docs/Glossary/SEO) by rendering content for the initial HTTP response that search engines use to calculate page rank.
219
+
220
+
Prerendering is enabled by default for interactive components.
221
+
222
+
Internal navigation for interactive routing doesn't involve requesting new page content from the server. Therefore, prerendering doesn't occur for internal page requests, including for [enhanced navigation](xref:blazor/fundamentals/routing#enhanced-navigation-and-form-handling). For more information, see [Static versus interactive routing](xref:blazor/fundamentals/routing#static-versus-interactive-routing), [Interactive routing and prerendering](xref:blazor/components/prerender#interactive-routing-and-prerendering), and [Enhanced navigation and form handling](xref:blazor/fundamentals/routing#enhanced-navigation-and-form-handling).
for .NET 10 work in this area. Update the following remark
226
+
if changes are made to the framework. -->
227
+
228
+
Disabling prerendering using the following techniques only takes effect for top-level render modes. If a parent component specifies a render mode, the prerendering settings of its children are ignored. This behavior is under investigation for possible changes with the release of .NET 10 in November, 2025.
229
+
230
+
To disable prerendering for a *component instance*, pass the `prerender` flag with a value of `false` to the render mode:
To disable prerendering for the entire app, indicate the render mode at the highest-level interactive component in the app's component hierarchy that isn't a root component.
243
+
244
+
For apps based on the Blazor Web App project template, a render mode assigned to the entire app is specified where the `Routes` component is used in the `App` component (`Components/App.razor`). The following example sets the app's render mode to Interactive Server with prerendering disabled:
Making a root component, such as the `App` component, interactive with the `@rendermode` directive at the top of the root component's definition file (`.razor`) isn't supported. Therefore, prerendering can't be disabled directly by the `App` component.
257
+
212
258
:::moniker range=">= aspnetcore-9.0"
213
259
214
260
## Detect rendering location, interactivity, and assigned render mode at runtime
@@ -306,52 +352,6 @@ In the preceding example:
306
352
307
353
:::moniker-end
308
354
309
-
## Blazor documentation examples for Blazor Web Apps
310
-
311
-
When using a Blazor Web App, most of the Blazor documentation example components ***require*** interactivity to function and demonstrate the concepts covered by the articles. When you test an example component provided by an article, make sure that either the app adopts global interactivity or the component adopts an interactive render mode.
312
-
313
-
## Prerendering
314
-
315
-
*Prerendering* is the process of initially rendering page content on the server without enabling event handlers for rendered controls. The server outputs the HTML UI of the page as soon as possible in response to the initial request, which makes the app feel more responsive to users. Prerendering can also improve [Search Engine Optimization (SEO)](https://developer.mozilla.org/docs/Glossary/SEO) by rendering content for the initial HTTP response that search engines use to calculate page rank.
316
-
317
-
Prerendering is enabled by default for interactive components.
318
-
319
-
Internal navigation for interactive routing doesn't involve requesting new page content from the server. Therefore, prerendering doesn't occur for internal page requests, including for [enhanced navigation](xref:blazor/fundamentals/routing#enhanced-navigation-and-form-handling). For more information, see [Static versus interactive routing](xref:blazor/fundamentals/routing#static-versus-interactive-routing), [Interactive routing and prerendering](xref:blazor/components/prerender#interactive-routing-and-prerendering), and [Enhanced navigation and form handling](xref:blazor/fundamentals/routing#enhanced-navigation-and-form-handling).
for .NET 10 work in this area. Update the following remark
323
-
if changes are made to the framework. -->
324
-
325
-
Disabling prerendering using the following techniques only takes effect for top-level render modes. If a parent component specifies a render mode, the prerendering settings of its children are ignored. This behavior is under investigation for possible changes with the release of .NET 10 in November, 2025.
326
-
327
-
To disable prerendering for a *component instance*, pass the `prerender` flag with a value of `false` to the render mode:
To disable prerendering for the entire app, indicate the render mode at the highest-level interactive component in the app's component hierarchy that isn't a root component.
340
-
341
-
For apps based on the Blazor Web App project template, a render mode assigned to the entire app is specified where the `Routes` component is used in the `App` component (`Components/App.razor`). The following example sets the app's render mode to Interactive Server with prerendering disabled:
Making a root component, such as the `App` component, interactive with the `@rendermode` directive at the top of the root component's definition file (`.razor`) isn't supported. Therefore, prerendering can't be disabled directly by the `App` component.
354
-
355
355
## Static server-side rendering (static SSR)
356
356
357
357
Components use static server-side rendering (static SSR). The component renders to the response stream and interactivity isn't enabled.
0 commit comments