Skip to content

Commit 9ba1d87

Browse files
authored
Blazor updates (#18365)
1 parent 4b20e4e commit 9ba1d87

37 files changed

Lines changed: 154 additions & 295 deletions

aspnetcore/blazor/call-dotnet-from-javascript.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ description: Learn how to invoke .NET methods from JavaScript functions in Blazo
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 04/07/2020
8+
ms.date: 05/19/2020
99
no-loc: [Blazor, "Identity", "Let's Encrypt", Razor, SignalR]
1010
uid: blazor/call-dotnet-from-javascript
1111
---
1212
# Call .NET methods from JavaScript functions in ASP.NET Core Blazor
1313

1414
By [Javier Calvarro Nelson](https://github.com/javiercn), [Daniel Roth](https://github.com/danroth27), [Shashikant Rudrawadi](http://wisne.co), and [Luke Latham](https://github.com/guardrex)
1515

16-
[!INCLUDE[](~/includes/blazorwasm-preview-notice.md)]
17-
1816
A Blazor app can invoke JavaScript functions from .NET methods and .NET methods from JavaScript functions. These scenarios are called *JavaScript interoperability* (*JS interop*).
1917

2018
This article covers invoking .NET methods from JavaScript. For information on how to call JavaScript functions from .NET, see <xref:blazor/call-javascript-from-dotnet>.

aspnetcore/blazor/call-javascript-from-dotnet.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ description: Learn how to invoke JavaScript functions from .NET methods in Blazo
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 04/07/2020
8+
ms.date: 05/19/2020
99
no-loc: [Blazor, "Identity", "Let's Encrypt", Razor, SignalR]
1010
uid: blazor/call-javascript-from-dotnet
1111
---
1212
# Call JavaScript functions from .NET methods in ASP.NET Core Blazor
1313

1414
By [Javier Calvarro Nelson](https://github.com/javiercn), [Daniel Roth](https://github.com/danroth27), and [Luke Latham](https://github.com/guardrex)
1515

16-
[!INCLUDE[](~/includes/blazorwasm-preview-notice.md)]
17-
1816
A Blazor app can invoke JavaScript functions from .NET methods and .NET methods from JavaScript functions. These scenarios are called *JavaScript interoperability* (*JS interop*).
1917

2018
This article covers invoking JavaScript functions from .NET. For information on how to call .NET methods from JavaScript, see <xref:blazor/call-dotnet-from-javascript>.

aspnetcore/blazor/call-web-api.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ description: Learn how to call a web API from a Blazor WebAssembly app using JSO
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 05/11/2020
8+
ms.date: 05/19/2020
99
no-loc: [Blazor, "Identity", "Let's Encrypt", Razor, SignalR]
1010
uid: blazor/call-web-api
1111
---
1212
# Call a web API from ASP.NET Core Blazor
1313

1414
By [Luke Latham](https://github.com/guardrex), [Daniel Roth](https://github.com/danroth27), and [Juan De la Cruz](https://github.com/juandelacruz23)
1515

16-
[!INCLUDE[](~/includes/blazorwasm-preview-notice.md)]
17-
1816
[Blazor WebAssembly](xref:blazor/hosting-models#blazor-webassembly) apps call web APIs using a preconfigured `HttpClient` service. Compose requests, which can include JavaScript [Fetch API](https://developer.mozilla.org/docs/Web/API/Fetch_API) options, using Blazor JSON helpers or with <xref:System.Net.Http.HttpRequestMessage>. The `HttpClient` service in Blazor WebAssembly apps is focused on making requests back to the server of origin. The guidance in this topic only pertains to Blazor WebAssembly apps.
1917

2018
[Blazor Server](xref:blazor/hosting-models#blazor-server) apps call web APIs using <xref:System.Net.Http.HttpClient> instances, typically created using <xref:System.Net.Http.IHttpClientFactory>. The guidance in this topic doesn't pertain to Blazor Server apps. When developing Blazor Server apps, follow the guidance in <xref:fundamentals/http-requests>.

aspnetcore/blazor/common/samples/3.x/BlazorWebAssemblySample/BlazorSample.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-rc1.20223.4" />
10-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-rc1.20223.4" PrivateAssets="all" />
11-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-rc1.20223.4" PrivateAssets="all" />
12-
<PackageReference Include="System.Net.Http.Json" Version="3.2.0-rc1.20217.1" />
9+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0" PrivateAssets="all" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0" PrivateAssets="all" />
12+
<PackageReference Include="System.Net.Http.Json" Version="3.2.0" />
1313
</ItemGroup>
1414

1515
</Project>

aspnetcore/blazor/components.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ Razor components in Blazor apps extensively use Razor syntax. If you aren't fami
7070

7171
When accessing the content on Razor syntax, pay special attention to the following sections:
7272

73-
* [Directives](xref:mvc/views/razor#directives): `@`-prefixed reserved keywords that typically change the way component markup is parsed or function.
74-
* [Directive attributes](xref:mvc/views/razor#directive-attributes): `@`-prefixed reserved keywords that typically change the way component elements are parsed or function.
73+
* [Directives](xref:mvc/views/razor#directives) &ndash; `@`-prefixed reserved keywords that typically change the way component markup is parsed or function.
74+
* [Directive attributes](xref:mvc/views/razor#directive-attributes) &ndash; `@`-prefixed reserved keywords that typically change the way component elements are parsed or function.
7575

7676
## Static assets
7777

@@ -971,7 +971,7 @@ Similarly, SVG images are supported in the CSS rules of a stylesheet file (*.css
971971
}
972972
```
973973

974-
However, inline SVG markup isn't supported in all scenarios. If you place an `<svg>` tag directly into a component file (*.razor*), basic image rendering is supported but many advanced scenarios aren't yet supported. For example, `<use>` tags aren't currently respected, and `@bind` can't be used with some SVG tags. We expect to address these limitations in a future release.
974+
However, inline SVG markup isn't supported in all scenarios. If you place an `<svg>` tag directly into a component file (*.razor*), basic image rendering is supported but many advanced scenarios aren't yet supported. For example, `<use>` tags aren't currently respected, and `@bind` can't be used with some SVG tags. For more information, see [SVG support in Blazor (dotnet/aspnetcore #18271)](https://github.com/dotnet/aspnetcore/issues/18271).
975975

976976
## Additional resources
977977

aspnetcore/blazor/debug.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ description: Learn how to debug Blazor apps.
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 04/16/2020
8+
ms.date: 05/19/2020
99
no-loc: [Blazor, "Identity", "Let's Encrypt", Razor, SignalR]
1010
uid: blazor/debug
1111
---
1212
# Debug ASP.NET Core Blazor WebAssembly
1313

1414
[Daniel Roth](https://github.com/danroth27)
1515

16-
[!INCLUDE[](~/includes/blazorwasm-preview-notice.md)]
17-
1816
Blazor WebAssembly apps can be debugged using the browser dev tools in Chromium-based browsers (Edge/Chrome). Alternatively you can debug your app using Visual Studio or Visual Studio Code.
1917

2018
Available scenarios include:
@@ -47,8 +45,6 @@ Debugging requires either of the following browsers:
4745

4846
## Enable debugging for Visual Studio and Visual Studio Code
4947

50-
Debugging is enabled automatically for new projects that are created using the ASP.NET Core 3.2 Preview 3 or later Blazor WebAssembly project template ([current release is 3.2 Preview 4](xref:blazor/get-started)).
51-
5248
To enable debugging for an existing Blazor WebAssembly app, update the *launchSettings.json* file in the startup project to include the following `inspectUri` property in each launch profile:
5349

5450
```json
@@ -68,7 +64,6 @@ The `inspectUri` property:
6864

6965
To debug a Blazor WebAssembly app in Visual Studio:
7066

71-
1. Ensure you have [installed the latest preview release of Visual Studio 2019 16.6](https://visualstudio.com/preview) (Preview 2 or later).
7267
1. Create a new ASP.NET Core hosted Blazor WebAssembly app.
7368
1. Press <kbd>F5</kbd> to run the app in the debugger.
7469
1. Set a breakpoint in *Counter.razor* in the `IncrementCount` method.
@@ -112,7 +107,7 @@ To debug a Blazor WebAssembly app in Visual Studio Code:
112107

113108
* If you get the following notification that additional setup is required to enable debugging, confirm that you have the correct extensions installed and JavaScript preview debugging enabled and then reload the window:
114109

115-
![Additional setup requried](https://devblogs.microsoft.com/aspnet/wp-content/uploads/sites/16/2020/03/vscode-additional-setup.png)
110+
![Additional setup required](https://devblogs.microsoft.com/aspnet/wp-content/uploads/sites/16/2020/03/vscode-additional-setup.png)
116111

117112
* A notification offers to add the required assets to the app for building and debugging. Select **Yes**:
118113

aspnetcore/blazor/dependency-injection.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ description: See how Blazor apps can inject services into components.
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 05/04/2020
8+
ms.date: 05/19/2020
99
no-loc: [Blazor, "Identity", "Let's Encrypt", Razor, SignalR]
1010
uid: blazor/dependency-injection
1111
---
1212
# ASP.NET Core Blazor dependency injection
1313

1414
By [Rainer Stropek](https://www.timecockpit.com) and [Mike Rousos](https://github.com/mjrousos)
1515

16-
[!INCLUDE[](~/includes/blazorwasm-preview-notice.md)]
17-
1816
Blazor supports [dependency injection (DI)](xref:fundamentals/dependency-injection). Apps can use built-in services by injecting them into components. Apps can also define and register custom services and make them available throughout the app via DI.
1917

2018
DI is a technique for accessing services configured in a central location. This can be useful in Blazor apps to:
@@ -142,7 +140,7 @@ Use multiple `@inject` statements to inject different services.
142140

143141
The following example shows how to use `@inject`. The service implementing `Services.IDataAccess` is injected into the component's property `DataRepository`. Note how the code is only using the `IDataAccess` abstraction:
144142

145-
[!code-razor[](dependency-injection/samples_snapshot/3.x/CustomerList.razor?highlight=2-3,23)]
143+
[!code-razor[](dependency-injection/samples_snapshot/3.x/CustomerList.razor?highlight=2-3,20)]
146144

147145
Internally, the generated property (`DataRepository`) uses the `InjectAttribute` attribute. Typically, this attribute isn't used directly. If a base class is required for components and injected properties are also required for the base class, manually add the `InjectAttribute`:
148146

aspnetcore/blazor/get-started.md

Lines changed: 33 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -5,163 +5,107 @@ description: Get started with Blazor by building a Blazor app with the tooling o
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 05/11/2020
8+
ms.date: 05/19/2020
99
no-loc: [Blazor, "Identity", "Let's Encrypt", Razor, SignalR]
1010
uid: blazor/get-started
1111
---
1212
# Get started with ASP.NET Core Blazor
1313

1414
By [Daniel Roth](https://github.com/danroth27) and [Luke Latham](https://github.com/guardrex)
1515

16-
[!INCLUDE[](~/includes/blazorwasm-preview-notice.md)]
17-
1816
To get started with Blazor, follow the guidance for your choice of tooling:
1917

2018
# [Visual Studio](#tab/visual-studio)
2119

22-
1. To create Blazor Server apps, install the latest version of [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) with the **ASP.NET and web development** workload.
23-
24-
To create Blazor Server and Blazor WebAssembly apps, install the latest preview of [Visual Studio 2019](https://visualstudio.microsoft.com/vs/preview/) with the **ASP.NET and web development** workload.
25-
26-
For information on the two Blazor hosting models, *Blazor WebAssembly* and *Blazor Server*, see <xref:blazor/hosting-models>.
27-
28-
1. Install the Blazor WebAssembly Preview template by running the following command:
29-
30-
```dotnetcli
31-
dotnet new -i Microsoft.AspNetCore.Components.WebAssembly.Templates::3.2.0-rc1.20223.4
32-
```
20+
1. Install the latest version of [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) with the **ASP.NET and web development** workload.
3321

3422
1. Create a new project.
3523

3624
1. Select **Blazor App**. Select **Next**.
3725

3826
1. Provide a project name in the **Project name** field or accept the default project name. Confirm the **Location** entry is correct or provide a location for the project. Select **Create**.
3927

40-
1. For a Blazor WebAssembly experience (Visual Studio 16.6 Preview 2 or later), choose the **Blazor WebAssembly App** template. For a Blazor Server experience (Visual Studio 16.4 or later), choose the **Blazor Server App** template. Select **Create**.
28+
1. For a Blazor WebAssembly experience, choose the **Blazor WebAssembly App** template. For a Blazor Server experience, choose the **Blazor Server App** template. Select **Create**.
29+
30+
For information on the two Blazor hosting models, *Blazor WebAssembly* and *Blazor Server*, see <xref:blazor/hosting-models>.
4131

4232
1. Press <kbd>Ctrl</kbd>+<kbd>F5</kbd> to run the app.
4333

4434
# [Visual Studio Code](#tab/visual-studio-code)
4535

4636
1. Install the [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.1).
4737

48-
1. Optionally install the [Blazor WebAssembly](xref:blazor/hosting-models#blazor-webassembly) preview template by running the following command:
49-
50-
```dotnetcli
51-
dotnet new -i Microsoft.AspNetCore.Components.WebAssembly.Templates::3.2.0-rc1.20223.4
52-
```
53-
54-
For information on the two Blazor hosting models, *Blazor WebAssembly* and *Blazor Server*, see <xref:blazor/hosting-models>.
55-
56-
> [!NOTE]
57-
> The [.NET Core SDK version 3.1.201 or later](https://dotnet.microsoft.com/download/dotnet-core/3.1) is **required** to use the 3.2 Preview Blazor WebAssembly template. Confirm the installed .NET Core SDK version by running `dotnet --version` in a command shell.
58-
5938
1. Install [Visual Studio Code](https://code.visualstudio.com/).
6039

6140
1. Install the latest [C# for Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) and the [JavaScript Debugger (Nightly)](https://marketplace.visualstudio.com/items?itemName=ms-vscode.js-debug-nightly) extension with `debug.javascript.usePreview` set to `true`.
6241

63-
1. For a Blazor Server experience, execute the following command in a command shell:
42+
1. For a Blazor WebAssembly experience, execute the following command in a command shell:
6443

6544
```dotnetcli
66-
dotnet new blazorserver -o WebApplication1
45+
dotnet new blazorwasm -o WebApplication1
6746
```
6847

69-
For a Blazor WebAssembly experience, execute the following command in a command shell:
48+
For a Blazor Server experience, execute the following command in a command shell:
7049

7150
```dotnetcli
72-
dotnet new blazorwasm -o WebApplication1
51+
dotnet new blazorserver -o WebApplication1
7352
```
7453

54+
For information on the two Blazor hosting models, *Blazor WebAssembly* and *Blazor Server*, see <xref:blazor/hosting-models>.
55+
7556
1. Open the *WebApplication1* folder in Visual Studio Code.
7657

7758
1. The IDE requests that you add assets to build and debug the project. Select **Yes**.
7859

79-
1. With Blazor Server, run the app using the Visual Studio Code debugger.
80-
81-
With Blazor WebAssembly, start the app using the **.NET Core Launch (Blazor Standalone)** launch configuration and then start the browser using the **.NET Core Debug Blazor Web Assembly in Chrome** launch configuration (requires Chrome). For more information, see <xref:blazor/debug#visual-studio-code>.
82-
83-
1. In a browser, navigate to `https://localhost:5001`.
60+
1. Press <kbd>Ctrl</kbd>+<kbd>F5</kbd> to run the app.
8461

8562
# [Visual Studio for Mac](#tab/visual-studio-mac)
8663

87-
> [!NOTE]
88-
> Blazor Server is supported in Visual Studio for Mac 8.4 or later, and Blazor WebAssembly support is included in Visual Studio for Mac 8.6 or later.
89-
9064
1. Install [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/).
9165

92-
1. In Visual Studio for Mac versions prior to 8.6:
93-
94-
* Select **File** > **New Solution** or create a **New** project from the **Start Window**.
95-
96-
* In the sidebar, select **.NET Core** > **App**.
97-
98-
* Select the **Blazor Server App** template. Select **Next**.
99-
100-
* Confirm the following configurations:
101-
102-
* **Target Framework** set to **.NET Core 3.1**.
103-
* **Authentication** set to **No Authentication**.
104-
105-
Select **Next**.
66+
1. Select **File** > **New Solution** or create a **New** project from the **Start Window**.
10667

107-
* In the **Project Name** field, name the app `WebApplication1`. Select **Create**.
68+
1. In the sidebar, select **Web and Console** > **App**.
10869

109-
* Select **Run** > **Start Without Debugging** to run the app *without the debugger*. Debugging isn't supported at this time.
70+
For a Blazor WebAssembly experience, choose the **Blazor WebAssembly App** template. For a Blazor Server experience, choose the **Blazor Server App** template. Select **Next**.
11071

111-
In the preview of Visual Studio for Mac version 8.6, which uses the [Preview channel](/visualstudio/mac/update):
112-
113-
* Select **File** > **New Solution** or create a **New** project from the **Start Window**.
114-
115-
* In the sidebar, select **Web and Console** > **App**.
116-
117-
* For a Blazor WebAssembly experience, choose the **Blazor WebAssembly App** template. For a Blazor Server experience, choose the **Blazor Server App** template. Select **Next**.
118-
119-
For information on the two Blazor hosting models, *Blazor WebAssembly* and *Blazor Server*, see <xref:blazor/hosting-models>.
72+
For information on the two Blazor hosting models, *Blazor WebAssembly* and *Blazor Server*, see <xref:blazor/hosting-models>.
12073

121-
* Confirm the following configurations:
74+
1. Confirm the following configurations:
12275

123-
* **Target Framework** set to **.NET Core 3.1**.
124-
* **Authentication** set to **No Authentication**.
76+
* **Target Framework** set to **.NET Core 3.1**.
77+
* **Authentication** set to **No Authentication**.
12578

126-
Select **Next**.
79+
Select **Next**.
12780

128-
* In the **Project Name** field, name the app `WebApplication1`. Select **Create**.
81+
1. In the **Project Name** field, name the app `WebApplication1`. Select **Create**.
12982

130-
* Select **Run** > **Start Without Debugging** to run the app *without the debugger*. Run the app with **Run** > **Start Debugging** or the Run (&#9654;) button to run the app *with the debugger*.
83+
1. Select **Run** > **Start Without Debugging** to run the app *without the debugger*. Run the app with **Run** > **Start Debugging** or the Run (&#9654;) button to run the app *with the debugger*.
13184

132-
If a prompt appears to trust the development certificate, trust the certificate and continue. The user and keychain passwords are required to trust the certificate.
85+
If a prompt appears to trust the development certificate, trust the certificate and continue. The user and keychain passwords are required to trust the certificate.
13386

13487
# [.NET Core CLI](#tab/netcore-cli/)
13588

13689
1. Install the [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.1).
13790

138-
1. Optionally install the Blazor WebAssembly preview template by running the following command:
139-
140-
```dotnetcli
141-
dotnet new -i Microsoft.AspNetCore.Components.WebAssembly.Templates::3.2.0-rc1.20223.4
142-
```
143-
144-
For information on the two Blazor hosting models, *Blazor WebAssembly* and *Blazor Server*, see <xref:blazor/hosting-models>.
145-
146-
> [!NOTE]
147-
> The [.NET Core SDK version 3.1.201 or later](https://dotnet.microsoft.com/download/dotnet-core/3.1) is **required** to use the 3.2 Preview Blazor WebAssembly template. Confirm the installed .NET Core SDK version by running `dotnet --version` in a command shell.
148-
149-
1. For a Blazor Server experience, execute the following commands in a command shell:
91+
1. For a Blazor WebAssembly experience, execute the following commands in a command shell:
15092

15193
```dotnetcli
152-
dotnet new blazorserver -o WebApplication1
94+
dotnet new blazorwasm -o WebApplication1
15395
cd WebApplication1
15496
dotnet run
15597
```
15698

157-
For a Blazor WebAssembly experience, execute the following commands in a command shell:
99+
For a Blazor Server experience, execute the following commands in a command shell:
158100

159101
```dotnetcli
160-
dotnet new blazorwasm -o WebApplication1
102+
dotnet new blazorserver -o WebApplication1
161103
cd WebApplication1
162104
dotnet run
163105
```
164106

107+
For information on the two Blazor hosting models, *Blazor WebAssembly* and *Blazor Server*, see <xref:blazor/hosting-models>.
108+
165109
1. In a browser, navigate to `https://localhost:5001`.
166110

167111
---
@@ -216,7 +160,10 @@ Run the app. The `Index` component has its own counter that increments by ten ea
216160

217161
## Next steps
218162

219-
<xref:tutorials/first-blazor-app>
163+
Build a Blazor app step-by-step:
164+
165+
> [!div class="nextstepaction"]
166+
> <xref:tutorials/first-blazor-app>
220167
221168
## Additional resources
222169

0 commit comments

Comments
 (0)