From 402f52a319a1d13c6d8f6743c5aa6213af73ef5f Mon Sep 17 00:00:00 2001
From: guardrex <1622880+guardrex@users.noreply.github.com>
Date: Mon, 11 Sep 2023 09:04:01 -0400
Subject: [PATCH 1/3] Blazor RC1 updates
---
aspnetcore/blazor/tooling.md | 26 +++++-
.../blazor/tutorials/build-a-blazor-app.md | 86 +++++++++++--------
.../tutorials/signalr-blazor-preview.md | 32 ++++---
3 files changed, 96 insertions(+), 48 deletions(-)
diff --git a/aspnetcore/blazor/tooling.md b/aspnetcore/blazor/tooling.md
index e43c4c660df2..aecf2797bfef 100644
--- a/aspnetcore/blazor/tooling.md
+++ b/aspnetcore/blazor/tooling.md
@@ -25,6 +25,9 @@ To create a Blazor app on Windows, use the following guidance:
* Install the latest version of [Visual Studio Preview](https://visualstudio.microsoft.com/vs/preview/) with the **ASP.NET and web development** workload.
+
+
* Create a new project:
* For a Blazor Web App experience (*recommended*), choose the **Blazor Web App** template. Select **Next**.
* For a Blazor WebAssembly experience, choose the **Blazor WebAssembly App** template, which includes demonstration code and Bootstrap, or the **Blazor WebAssembly App Empty** template without demonstration code and Bootstrap. Select **Next**.
@@ -58,9 +61,12 @@ To create a Blazor app on Windows, use the following guidance:
* For a Blazor Web App in the **Additional information** dialog:
- * To enable interactivity with server-side rendering (SSR), select the **Use interactive server components** checkbox.
+ * Interactivity with server-side rendering (SSR) is enabled by default with the **Use interactive server components** checkbox. To disable SSR, deselect the checkbox.
* To enable interactivity with client-side rendering (CSR), select the **Use interactive client components** checkbox.
+
+
:::moniker-end
:::moniker range="< aspnetcore-8.0"
@@ -130,12 +136,18 @@ Create a new project:
dotnet new blazor -o BlazorApp
```
-
+
+
+ Interactivity with server-side rendering (SSR) is enabled by default. If you want to disable SSR, pass `--use-server false`:
+
+ ```dotnetcli
+ dotnet new blazor -o Blazor App --use-server false
+ ```
- To enable interactivity with server-side rendering (SSR), add the `--use-server` option to the command:
+ To enable interactivity with client-side rendering (CSR), add the `--use-wasm` option to the command:
```dotnetcli
- dotnet new blazor -o BlazorApp --use-server
+ dotnet new blazor -o BlazorApp --use-wasm
```
* For a Blazor WebAssembly experience with demonstration code and Bootstrap, execute the following command:
@@ -538,6 +550,9 @@ The Blazor framework provides templates for creating new apps. The templates are
:::moniker range=">= aspnetcore-8.0"
+
+
* Blazor Web App project template (*recommended*): `blazor`
* Blazor WebAssembly project templates: `blazorwasm`, `blazorwasm-empty`
@@ -569,6 +584,9 @@ For more information on template options, see the following resources:
-->
+
+
* The *.NET default templates for dotnet new* article in the .NET Core documentation:
* [`blazorwasm`](/dotnet/core/tools/dotnet-new-sdk-templates#blazorwasm) (includes `blazorwasm-empty` options)
* Passing the help option (`-h` or `--help`) to the [`dotnet new`](/dotnet/core/tools/dotnet-new) CLI command in a command shell:
diff --git a/aspnetcore/blazor/tutorials/build-a-blazor-app.md b/aspnetcore/blazor/tutorials/build-a-blazor-app.md
index 52e2039ae652..b2ceeecad1ca 100644
--- a/aspnetcore/blazor/tutorials/build-a-blazor-app.md
+++ b/aspnetcore/blazor/tutorials/build-a-blazor-app.md
@@ -26,6 +26,8 @@ At the end of this tutorial, you'll have a working todo list app.
## Prerequisites
+
+
:::moniker range=">= aspnetcore-8.0"
[Download and install the .NET 8.0 Preview](https://dotnet.microsoft.com/download/dotnet/8.0)
@@ -44,11 +46,13 @@ At the end of this tutorial, you'll have a working todo list app.
Create a new Blazor app named `TodoList` in a command shell:
+
+
```dotnetcli
-dotnet new blazor -o TodoList --use-server
+dotnet new blazor -o TodoList
```
-The `-o|--output` option creates a folder for the project. If you've created a folder for the project and the command shell is open in that folder, omit the `-o|--output` option and value to create the project. The `--use-server` option enables interactivity with server-side rendering (SSR).
+The `-o|--output` option creates a folder for the project. If you've created a folder for the project and the command shell is open in that folder, omit the `-o|--output` option and value to create the project.
:::moniker-end
@@ -80,12 +84,28 @@ cd TodoList
Add a new `Todo` Razor component to the app using the following command:
+:::moniker range=">= aspnetcore-8.0"
+
+
+
+```dotnetcli
+dotnet new razorcomponent -n Todo -o Components/Pages
+```
+
+The `-n|--name` option in the preceding command specifies the name of the new Razor component. The new component is created in the project's `Components/Pages` folder with the `-o|--output` option.
+
+:::moniker-end
+
+:::moniker range="< aspnetcore-8.0"
+
```dotnetcli
dotnet new razorcomponent -n Todo -o Pages
```
The `-n|--name` option in the preceding command specifies the name of the new Razor component. The new component is created in the project's `Pages` folder with the `-o|--output` option.
+:::moniker-end
+
> [!IMPORTANT]
> Razor component file names require a capitalized first letter. Open the `Pages` folder and confirm that the `Todo` component file name starts with a capital letter `T`. The file name should be `Todo.razor`.
@@ -96,7 +116,7 @@ Open the `Todo` component in any file editor and make the following changes at t
* Add an `@page` Razor directive with a relative URL of `/todo`.
-* Add the `[RenderModeServer]` attribute. The attribute indicates that for this component the render mode should be server-side rendering (SSR), which means that the `Todo` component is rendered interactively on the server via Blazor Server hosting with server-side prerendering.
+* Add the `[RenderModeServer]` attribute. The attribute indicates that for this component the render mode should be server-side rendering (SSR), which means that the `Todo` component is rendered interactively on the server via Blazor Server hosting with server-side prerendering.
* Add a page title with the `PageTitle` component, which enables adding an HTML `
` element to the page.
:::moniker-end
@@ -116,10 +136,12 @@ Open the `Todo` component in any file editor and add an `@page` Razor directive
:::moniker-end
-`Pages/Todo.razor`:
+`Todo.razor`:
:::moniker range=">= aspnetcore-8.0"
+
+
:::code language="razor" source="build-a-blazor-app/8.0/Todo0.razor" highlight="1-4":::
:::moniker-end
@@ -148,7 +170,7 @@ Open the `Todo` component in any file editor and add an `@page` Razor directive
:::moniker-end
-Save the `Pages/Todo.razor` file.
+Save the `Todo.razor` file.
Add the `Todo` component to the navigation bar.
@@ -156,39 +178,27 @@ The `NavMenu` component is used in the app's layout. Layouts are components that
In the navigation element (`