File tree Expand file tree Collapse file tree
security/blazor/webassembly Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ description: Learn how to call a web API from a Blazor WebAssembly app using JSO
55monikerRange : ' >= aspnetcore-3.1'
66ms.author : riande
77ms.custom : mvc
8- ms.date : 04/23 /2020
8+ ms.date : 05/04 /2020
99no-loc : [Blazor, SignalR]
1010uid : blazor/call-web-api
1111---
@@ -35,7 +35,7 @@ Reference the [System.Net.Http.Json](https://www.nuget.org/packages/System.Net.H
3535In ` 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 )
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ description: Learn how to configure Blazor WebAssembly for additional security s
55monikerRange : ' >= aspnetcore-3.1'
66ms.author : riande
77ms.custom : mvc
8- ms.date : 04/27 /2020
8+ ms.date : 05/04 /2020
99no-loc : [Blazor, SignalR]
1010uid : security/blazor/webassembly/additional-scenarios
1111---
@@ -63,7 +63,7 @@ The `AuthorizationMessageHandler` service can be used with `HttpClient` to attac
6363In 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 });
You can’t perform that action at this time.
0 commit comments