Update additional-scenarios.md (#23650)

pull/23651/head
johndhunter 2021-10-26 17:42:37 +01:00 committed by GitHub
parent 5265cf454c
commit f6730f65c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -34,6 +34,7 @@ using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
...
// AddHttpClient is an extension in Microsoft.Http.Extensions
builder.Services.AddHttpClient("WebAPI",
client => client.BaseAddress = new Uri("https://www.example.com/base"))
.AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
@ -98,6 +99,7 @@ In `Program.cs`, `CustomAuthorizationMessageHandler` is registered as a scoped s
```csharp
builder.Services.AddScoped<CustomAuthorizationMessageHandler>();
// AddHttpClient is an extension in Microsoft.Http.Extensions
builder.Services.AddHttpClient("WebAPI",
client => client.BaseAddress = new Uri("https://www.example.com/base"))
.AddHttpMessageHandler<CustomAuthorizationMessageHandler>();
@ -210,6 +212,7 @@ using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
...
// AddHttpClient is an extension in Microsoft.Http.Extensions
builder.Services.AddHttpClient<WeatherForecastClient>(
client => client.BaseAddress = new Uri("https://www.example.com/base"))
.AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
@ -237,6 +240,7 @@ The handler can be further configured with <xref:Microsoft.AspNetCore.Components
In `Program.cs`:
```csharp
// AddHttpClient is an extension in Microsoft.Http.Extensions
builder.Services.AddHttpClient<WeatherForecastClient>(
client => client.BaseAddress = new Uri("https://www.example.com/base"))
.AddHttpMessageHandler(sp => sp.GetRequiredService<AuthorizationMessageHandler>()
@ -257,6 +261,7 @@ If the Blazor WebAssembly app ordinarily uses a secure default <xref:System.Net.
In `Program.cs`:
```csharp
// AddHttpClient is an extension in Microsoft.Http.Extensions
builder.Services.AddHttpClient("WebAPI.NoAuthenticationClient",
client => client.BaseAddress = new Uri("https://www.example.com/base"));
```