Skip to content

Commit 658f583

Browse files
authored
Blazor WASM HttpClient registration patch (#18125)
1 parent bf0b644 commit 658f583

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

aspnetcore/blazor/call-web-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ 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: 04/23/2020
8+
ms.date: 05/04/2020
99
no-loc: [Blazor, SignalR]
1010
uid: blazor/call-web-api
1111
---
@@ -35,7 +35,7 @@ Reference the [System.Net.Http.Json](https://www.nuget.org/packages/System.Net.H
3535
In `Program.Main`, add an `HttpClient` service if it doesn't already exist:
3636

3737
```csharp
38-
builder.Services.AddSingleton(
38+
builder.Services.AddTransient(sp =>
3939
new HttpClient
4040
{
4141
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)

aspnetcore/security/blazor/webassembly/additional-scenarios.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to configure Blazor WebAssembly for additional security s
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 04/27/2020
8+
ms.date: 05/04/2020
99
no-loc: [Blazor, SignalR]
1010
uid: security/blazor/webassembly/additional-scenarios
1111
---
@@ -63,7 +63,7 @@ The `AuthorizationMessageHandler` service can be used with `HttpClient` to attac
6363
In the following example, `AuthorizationMessageHandler` configures an `HttpClient` in `Program.Main` (*Program.cs*):
6464

6565
```csharp
66-
builder.Services.AddSingleton(sp =>
66+
builder.Services.AddTransient(sp =>
6767
{
6868
return new HttpClient(sp.GetRequiredService<AuthorizationMessageHandler>()
6969
.ConfigureHandler(
@@ -475,7 +475,7 @@ public class Program
475475
var builder = WebAssemblyHostBuilder.CreateDefault(args);
476476
builder.RootComponents.Add<App>("app");
477477

478-
builder.Services.AddSingleton(new HttpClient
478+
builder.Services.AddTransient(new HttpClient
479479
{
480480
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
481481
});

0 commit comments

Comments
 (0)